I've been looking around at some of the answers posted here about this error but have had no luck. I'm hoping to get some clarification about what's going on. my error is as follows:
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/maven/commons-io/commons-io/pom.xml File1: /home/colin/.gradle/caches/modules-2/files-2.1/org.apache.commons/commons-io/1.3.2/b6dde38349ba9bb5e6ea6320531eae969985dae5/commons-io-1.3.2.jar File2: /home/colin/.gradle/caches/modules-2/files-2.1/commons-io/commons-io/1.3.2/b6dde38349ba9bb5e6ea6320531eae969985dae5/commons-io-1.3.2.jar
I've done
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
}
in the app > build.gradle
file, but the problem persists. Is there somewhere else I should put this, or perhaps just delete some file? Or perhaps I've excluded too many files - Should I omit some of these lines, and if so which ones? I also tried moving the dependencies in to the top, above Android
to no avail.
Furthermore I'm a little confused about some of the advice given in these posts. What is the operating difference between Exclude
and PickFirst
? They seem to be interchangeable but express very different ideas. It seems I'm required to include a license when uploading to the app store, so if I'm excluding it here in order to get the app to compile, where do I include it later on when I'm ready to upload? I hope someone can shed some more light on what's going on here.
I had to add the following lines to packagingOptions {}
exclude 'META-INF/maven/commons-io/commons-io/pom.xml'
exclude 'META-INF/maven/commons-io/commons-io/pom.properties'
My problem was pretty foolish; when including exclude 'META-INF/maven/commons-io/commons-io/pom.xml'
I got an error that looked very similar to the first one, but was in fact different. adding exclude 'META-INF/maven/commons-io/commons-io/pom.properties'
finally got everything working. Still not sure why exactly I have to take these steps though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With