Duplicate files copied in APK META-INF/maven/com.s

2019-01-18 23:31发布

问题:

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

回答1:

Add to build.gradle:

android {
...
    packagingOptions {
         exclude 'META-INF/maven/com.squareup/otto/pom.xml'
}

Also, instead of exclude you could use pickFirst