2

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.

emmanuel2004
  • 117
  • 2
  • 14

1 Answers1

3

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

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

Take a look at this question.

Community
  • 1
  • 1
Montoya
  • 2,819
  • 3
  • 37
  • 65
  • You need to change * to the name of the 'META-INF' file you want to exclude. Just exclude the files you want one by one and it should work. – Montoya Aug 07 '16 at 09:33
  • Yes but I don't know how many files it is - so I feel stupid excluding them one by one since it just complains about the next file. And will it work when excluded all of them? – emmanuel2004 Aug 07 '16 at 10:23
  • I had a similar problem on my app, I've excluded about 10 files one by one until it was able to compile and it worked. – Montoya Aug 07 '16 at 10:25
  • Thanks! It was only five files or so and than it worked. I was a bit pessimistic ;) – emmanuel2004 Aug 07 '16 at 12:34