Android - butterKnife与realm同时依赖;可能出现app:transformResourcesWithMergeJavaResForDebug错误



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/services/javax.annotation.processing.Processor	File1: C:\Users\Administrator\.gradle\caches\modules-2\files-2.1\com.jakewharton\butterknife\7.0.1\d5d13ea991eab0252e3710e5df3d6a9d4b21d461\butterknife-7.0.1.jar	File2: C:\Users\Administrator\.gradle\caches\modules-2\files-2.1\io.realm\realm-android\0.87.5\ab4e1fead1380252dad0e95658e53ea0c113e89c\realm-android-0.87.5.jar

// butterKnife
compile 'com.jakewharton:butterknife:7.0.1'
//realm
compile 'io.realm:realm-android:0.87.5' // dependency for realm-database API (http://realm.io)

解决方案:在app 的build.gradle的文件下  android下添加
android {
 
  
packagingOptions {
    exclude 'META-INF/NOTICE' // will not include NOTICE file
    exclude 'META-INF/LICENSE' // will not include LICENSE file
    exclude 'META-INF/services/javax.annotation.processing.Processor'
}
}

你可能感兴趣的:(Android-error)