Duplicated files copied to the META-INF APK when Gradle building

I searched around for some answers posted here about this error, but no luck. I hope to get some clarification about what is happening. my mistake is this:

Error: execution failed for task ': app: transformResourcesWithMergeJavaResForDebug'. com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: duplicate files copied to the 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 did

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 , but the problem persists. Is there somewhere else that I should put this, or maybe just delete some file? Or maybe I deleted too many files. Should I skip some of these lines, and if so, which ones? I also tried moving the dependencies on top, above Android no avail.

Also, I'm a little confused by some of the tips provided in these posts. What is the difference between Exclude and PickFirst ? They seem interchangeable, but express very different ideas. It seems that I should include the license when uploading to the application store, so if I exclude it here to force the application to compile, where can I enable it later when I download? I hope someone can shed light on what is happening here.

+6
source share
1 answer

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 dumb; when I turned on exclude 'META-INF/maven/commons-io/commons-io/pom.xml' I got an error that looked very similar to the first, but actually was different. adding exclude 'META-INF/maven/commons-io/commons-io/pom.properties' finally everything works. Still not sure why I should follow these steps.

+13
source

All Articles