Error:Execution failed for task ':app:transformResourcesWithMergeJavaResFor'.
com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK jsr305_annotations/Jsr305_annotations.gwt.xml
File1:\app\build\intermediates\exploded-aar\google-maps-sdk-m4b\jars\classes.jar
File2:\app\build\intermediates\exploded-aar\com.google.android.gms\play-services-basement\9.0.0\jars\classes.jar
Add below text in build.gradle inside the android{} section to solve the problem.
android {
...
packagingOptions {
exclude 'jsr305_annotations/Jsr305_annotations.gwt.xml'
exclude 'build-data.properties'
}
...
}
If getting more error DuplicateFileException add file with exclude.
Like :
Error
Duplicate files copied in APK jsr305_annotations/Jsr305_annotations.gwt.xml
Solution
exclude 'jsr305_annotations/Jsr305_annotations.gwt.xml'
Adding this to your gradle file will solve your problem:
packagingOptions {
exclude 'jsr305_annotations/Jsr305_annotations.gwt.xml'
}
Related
I have downloaded the Jackson2 libraries to include in an android class. I get this error upon building:
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/LICENSE File1: \app\libs\jackson-core-2.9.1.jar File2: \app\libs\jackson-databind-2.9.1.jar File3: \app\libs\jackson-annotations-2.9.1.jar
I searched the internet and found this to be the most common answer:
packagingOptions {
exclude "META-INF/license.txt"
}
However, this doesn't fix the issue above.
You need to exclude the exact file name. From the error log, you can see that the duplicated file is META-INF/LICENSE (be aware of the case-sensitive) :
Duplicate files copied in APK META-INF/LICENSE
So, exclude it:
packagingOptions {
exclude 'META-INF/LICENSE'
}
I'm getting below mentioned error when I'm trying to run my application.
Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForAmazonCheezCoverage'.
com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/maven/com.squareup/otto/pom.xml
File1: /Users/afourtest/.gradle/caches/modules-2/files-2.1/com.crashlytics.android/crashlytics/1.1.13/e821eafa1bf489a26bdb71f95078c26785b37a1/crashlytics-1.1.13.jar
File2: /Users/afourtest/.gradle/caches/modules-2/files-2.1/com.squareup/otto/1.3.7/69d90fd7fb70e54746e26c10454c220e40a775ce/otto-1.3.7.jar
My app build.gradle is here
Add to build.gradle:
android {
...
packagingOptions {
exclude 'META-INF/maven/com.squareup/otto/pom.xml'
}
Also, instead of exclude you could use pickFirst
I am working on a project for a client. The project seems to work fine in the old Android Studio, but ever since I updated my studio to 2.2.2, I am getting the sync error when trying to run the app, the error message is as posted below.
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/LICENSE
File1: /home/empressum/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpclient-android/4.3.5.1/eecbb0b998e77629862a13d957d552b3be58fc4e/httpclient-android-4.3.5.1.jar
File2: /home/empressum/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpmime/4.3/5b0002c5fb66867ca919be0fbd86de1cfaf76da7/httpmime-4.3.jar
You might also want to check if you have 2 references of the same library or .jar included and remove the duplicate reference.
Guess you are using dependency which is conflicting with androids supplied jars. Add
compile('org.apache.httpcomponents:httpmime:4.3.6') {
exclude module: 'httpclient'
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}
in your gradle.
Add following into respective build.gradle file
android {
packagingOptions {
exclude 'META-INF/ASL2.0'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/MANIFEST.MF'
}
}
You are using two many libraries files for http call instead use jar file on libs or add some dependency in gradle.
The error went when I downloaded the project zip file again and run it. But this time when Android Studio asked me to update the gradle file, I denied. I dont know if this explains the error, but now the project is running fine on any device I connect.
I'm having trouble adding the Jackson Parser dependency to my project.
Currently I'm using these lines of code on my build.gradle:
compile 'com.fasterxml.jackson.core:jackson-core:2.7.2'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.7.2'
compile 'com.fasterxml.jackson.core:jackson-databind:2.7.2'
The only Class I need is the ObjectMapper that I know it is in databind package. When I added these lines in the gradle I pressed the sync and everything did correctly.
The problem was running the project on the emulator, this error showed up in Messages in Android Studio:
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/NOTICE File1:
C:\Users\Igor.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-databind\2.7.2\84ffa765dd258dbab8695963c41308b054f3a1cb\jackson-databind-2.7.2.jar
File2:
C:\Users\Igor.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-core\2.7.2\8b8310381b690e317f5f0574e9b2dd7034778b4c\jackson-core-2.7.2.jar
I tried to left only the databind library but I got no lucky with that. Same error.
compile 'com.fasterxml.jackson.core:jackson-databind:2.7.2'
I tried Build -> Clean Project and deleting the .gradle/cache but no luck either.
I have no clue what this could be. Any suggestions?
Add
android {
...
packagingOptions {
exclude 'META-INF/NOTICE' // It is not include NOTICE file
exclude 'META-INF/LICENSE' // It is not include LICENSE file
}
...
}
in your build.gradle .
To resolve the problem entirely I added all of these:
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
implementation 'com.squareup.retrofit2:converter-jackson:2.7.2'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.10.3'
implementation 'com.fasterxml.jackson.core:jackson-core:2.10.3'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.10.3'
try this..
ref :-
https://mobikul.com/how-to-use-jackson-parser/
I'm getting below mentioned error when I'm trying to run my application.
Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForAmazonCheezCoverage'.
com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/maven/com.squareup/otto/pom.xml
File1: /Users/afourtest/.gradle/caches/modules-2/files-2.1/com.crashlytics.android/crashlytics/1.1.13/e821eafa1bf489a26bdb71f95078c26785b37a1/crashlytics-1.1.13.jar
File2: /Users/afourtest/.gradle/caches/modules-2/files-2.1/com.squareup/otto/1.3.7/69d90fd7fb70e54746e26c10454c220e40a775ce/otto-1.3.7.jar
My app build.gradle is here
Add to build.gradle:
android {
...
packagingOptions {
exclude 'META-INF/maven/com.squareup/otto/pom.xml'
}
Also, instead of exclude you could use pickFirst