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.
Related
I tried building my app but it wouldn't build and show this error.
Execution failed for task ':app:mergeDebugJavaResource'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.MergeJavaResWorkAction
> 2 files found with path 'kotlin/internal/internal.kotlin_builtins' from inputs:
- C:\Users\user\.gradle\caches\transforms-3\1203ed0043761220f2e7b9faa528e635\transformed\jetified-kotlin-compiler-embeddable-1.5.31.jar
- C:\Users\user\.gradle\caches\transforms-3\a14ecf8d638c881bd231708fc869e941\transformed\jetified-kotlin-stdlib-1.6.0.jar
Adding a packagingOptions block may help, please refer to
https://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.PackagingOptions.html
for more information
I tried
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/ASL2.0'
exclude 'internal.kotlin_builtins'
but this doesn't work, I have also tried to Invalidate caches and Restart but to no avail.
I am still learning how to code in android studio so I apologize in advance for my lack of knowledge.
The correct path should be:
exclude 'kotlin/internal/internal.kotlin_builtins'
After installing a plugin, I'm getting the following error:
Execution failed for task ':transformResourcesWithMergeJavaResForDebug'.
com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/DEPENDENCIES
File1: C:\Users\Vinicius\Desktop\webapps\paypadapp\platforms\android\libs\httpcore-4.3.2.jar
File2: C:\Users\Vinicius\Desktop\webapps\paypadapp\platforms\android\libs\httpclient-4.3.3.jar
File3: C:\Users\Vinicius\Desktop\webapps\paypadapp\platforms\android\libs\httpmime-4.3.3.jar
When doing a search, I found the following solution
Add this in android manifest:
packagingOptions {
exclude 'META-INF/NOTICE' // will not include NOTICE file
exclude 'META-INF/LICENSE' // will not include LICENSE file
// as noted by #Vishnuvathsan you may also need to include
// variations on the file name. It depends on your dependencies.
// Some other common variations on notice and license file names
exclude 'META-INF/notice'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license'
exclude 'META-INF/license.txt'
}
But where do I add that in ionic / cordova?
I created an ionic project from scratch and installed the plugin, the same error occurs
In my android application i have multiple third party libraries in libs folder
ex -: httpcore-4.2.4.jar , httpmime-4.2.5.jar,twitter4j-core-4.0.1.jar
these libraries are not duplicated and i'm pretty sure with that , but when i create the proguard release i get this error
(Duplicate zip entry [twitter4j-core-4.0.1.jar:META-INF/MANIFEST.MF])
.... (This error occurs for all of the library(libs)
I refereed this link to overcome with issue , i tried every option of it , but no luck with that ,
Proguard warnings "can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry)"
Is there any way to specify filters on the input jar
Your libraries are not duplicated, but some info files inside of several libraries are.
The best solution is to include in your build.gradle. inside the "android" section something like this:
android{
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LGPL2.1'
}
}
By the error message that you included here I will guess that adding this exclude will solve your problem:
exclude "META-INF/MANIFEST.MF"
I'm getting a duplicate files error when attempting to build with Gradle.
Error:Execution failed for task ':pauwowandroid:packageDebug'.
> Duplicate files copied in APK LICENSE
File 1: /Users/jasonrobinson/.gradle/caches/modules-2/files-2.1/org.sonatype.sisu.inject/cglib/2.2.1-v20090111/7ce5e983fd0e6c78346f4c9cbfa39d83049dda2/cglib-2.2.1-v20090111.jar
File 2: /Users/jasonrobinson/.gradle/caches/modules-2/files-2.1/org.sonatype.sisu.inject/cglib/2.2.1-v20090111/7ce5e983fd0e6c78346f4c9cbfa39d83049dda2/cglib-2.2.1-v20090111.jar
This is different from other similar errors in that it's complaining the duplicate is in the same file. These are my exclusions:
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/DEPENDENCIES'
}
I still get this error. It's with one particular dependency: Mockito. If I remove that dependency, the error goes away.
Try to add the following exclude:
exclude 'LICENSE.txt'
This should fix it.
I'm getting this error (AGAIN!) on android. Recently updated to the latest version of gradle 0.7.3 and also to the latest version of espresso framework (1.1) and I'm back to the infamous "duplicate file" bug.
Execution failed for task ':mobile:packageTesttype'.
Duplicate files copied in APK META-INF/LICENSE.txt File 1: /Users/mwolfe/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpmime/4.2.4/dba4d4d224e2ca872af5be8d2992777583145478/httpmime-4.2.4.jar
File 2:
/Users/mwolfe/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpmime/4.2.4/dba4d4d224e2ca872af5be8d2992777583145478/httpmime-4.2.4.jar
I already have set my build.gradle file to exclude these files. The app assembles fine for debug/release and runs fine, However building/running for test it fails. Specifically when I try to run instrument tests with the followng command is when I get the error mentioned above.
gradle connectedCheck
I have a library project as well and have tried every which way to add the exclusions to both build files. This specific dependency is from the library project. Both of them have the following exclusions
packagingOptions {
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE.txt'
}
I've also tried with removing the META-INF part above as it shows in the espresso docs here: https://code.google.com/p/android-test-kit/wiki/Espresso#Espresso_Setup_Instructions
I know I can delete these files from the jars but it's quite a pain.
Try to include other variations too...Copy and paste this:
packagingOptions {
exclude 'LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
}