0
votes
  • Android Studio: 2.2.2
  • Gradle: 2.2.2

I have this common problem but the usual solutions don't seem to be helping. I've even broken it down to just this one library on a new solution. To replicate, fire up a new Android project and simply drop this one line into your dependencies.

compile 'com.sun.jersey:jersey-client:1.13'

Here is the error.

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/jersey-module-version File1: /Users/me/.gradle/caches/modules-2/files-2.1/com.sun.jersey/jersey-client/1.13/ec38c57a78940bf5f8f5971307ca89406849647/jersey-client-1.13.jar File2: /Users/me/.gradle/caches/modules-2/files-2.1/com.sun.jersey/jersey-core/1.13/4326a56dc6b2d67b7313905c353e1af225bb164f/jersey-core-1.13.jar

I have tried

I can't figure out what to exclude. Has anybody see this? Easy to replicate, try it out.

1
You tried excluding, META-INF/jersey-module-version? Because none of those answers say thatOneCricketeer

1 Answers

1
votes

Well, looks like just another example of a problem with these builds. I was able to block it by just looking at the error. So the error told me the duplicate was jersey-module-version. I went into my libraries and browsed the folders to the META-INF and found that file there, no extension.

So it was a matter of excluding it.

packagingOptions {
    exclude 'META-INF/jersey-module-version'
}

What is strange is that this is supposed to be fixed.

https://code.google.com/p/android/issues/detail?id=158630#makechanges