Duplicate files copied in APK META-INF on many lib

2019-05-26 22:02发布

问题:

I get this error when trying to build APK,

Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.

com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/services/com.sun.jersey.spi.inject.InjectableProvider File1: /home/xxxxxxx/.gradle/caches/modules-2/files- 2.1/com.sun.jersey/jersey-core/1.19.1/4282d106f2acd5051bd9bc2935ed9a2920c9385/jersey-core-1.19.1.jar File2: /home/xxxxxxx/.gradle/caches/modules-2/files-2.1/com.sun.jersey.contribs/jersey- multipart/1.19.1/b8700842c5005dab05831319bc8f072d51e26396/jersey-multipart-1.19.1.jar

I can't find that I should have duplicates of dependencies.

Works when I exclude the file in build.gradle, but then I just get som other file that causing duplicate error.. feel strange that I should write this long exclude list.

回答1:

You can exclude this files on your build.gradle file:

packagingOptions {
    exclude 'META-INF/**'
    exclude 'META-INF/**'
}

Take a look at this question.