DuplicateFileException: Duplicate files copied in APK project.properties [duplicate] - android

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

Related

Android Duplicate File Exception

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'
}

Duplicate files copied in APK META-INF/LICENSE

Error:Execution failed for task ':openpayandroid:transformResourcesWithMergeJavaResForRelease'.
com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/LICENSE
File1: /Users/ederpadilla/Downloads/driveappuble-drive-android-484430cd00e7/openpayandroid/libs/jackson-core-2.8.2.jar
File2: /Users/ederpadilla/Downloads/driveappuble-drive-android-484430cd00e7/openpayandroid/libs/jackson-core-asl-1.9.11.jar
Add this code in your app gradle file
android {
...
packagingOptions {
exclude 'META-INF/LICENSE'
}
}

Android get DuplicateFileException Error for Retrofit and Retrofit Adapter

after installing this libraries on project:
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile 'io.reactivex.rxjava2:rxjava:2.0.1'
compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
i get this 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/rxjava.properties
File1: /Users/mahdi/.gradle/caches/modules-2/files-2.1/io.reactivex.rxjava2/rxjava/2.0.1/57f850a6b317e5582f1dbaff10a9e7d7e1fcdcfb/rxjava-2.0.1.jar
File2: /Users/mahdi/.gradle/caches/modules-2/files-2.1/io.reactivex/rxjava/1.1.5/ece7b5d0870e66d8226dab6dcf47a2b12afff061/rxjava-1.1.5.jar
I'm not sure whats problem, some documents installed them like with my solution.
packagingOptions {
exclude 'META-INF/io.reactivex.rxjava2/rxjava/2.0.1/57f850a6b317e5582f1dbaff10a9e7d7e1fcdcfb/rxjava.properties'
exclude 'META-INF/io.reactivex/rxjava/rxjava.properties'
}
problem resolved:
packagingOptions {
exclude 'META-INF/rxjava.properties'
}

DuplicateFileException m4b + play services 9.0

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'
}

Duplicate files copied in APK META-INF/maven/com.squareup/otto/pom.xml

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

Categories

Resources