添加Realm依赖性后,Butterknife和Realm之间出现重复的文件异常

时间:2016-05-17 18:40:10

标签: android gradle android-gradle realm butterknife

我试图将Realm添加到我的项目中但是在运行时我从gradle中得到以下构建错误:

Error:Execution failed for task ':sdksampleapp: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: /Users/name/.gradle/caches/modules-2/files-2.1/com.jakewharton/butterknife/7.0.1/d5d13ea991eab0252e3710e5df3d6a9d4b21d461/butterknife-7.0.1.jar
    File2: /Users/name/.gradle/caches/modules-2/files-2.1/io.realm/realm-android/0.84.1/b86074e6240f0f876701810a047b0261f7bd060e/realm-android-0.84.1.jar

我尝试过添加:

packagingOptions {
        exclude 'META-INF/services/javax.annotation.processing.Processor'
    }

到我的android {}块中的build.gradle,但这似乎无法解决问题。

我正在通过

添加Realm
compile 'io.realm:realm-android:0.84.1'

尝试过清洁/重建等但在尝试运行项目时仍然遇到问题。有什么想法吗?

1 个答案:

答案 0 :(得分:0)

我正在使用com.jakewharton:butterknife:7.0.1io.realm:realm-gradle-plugin:0.90.1。它对我来说很好。

packagingOptions {
        exclude 'META-INF/services/javax.annotation.processing.Processor'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
    }