Home » Android » android – DuplicateFileException m4b + play services 9.0

android – DuplicateFileException m4b + play services 9.0

Posted by: admin June 15, 2020 Leave a comment

Questions:

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

How to&Answers:

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'

Answer:

Adding this to your gradle file will solve your problem:

packagingOptions {
    exclude 'jsr305_annotations/Jsr305_annotations.gwt.xml'
}