0

Am trying to add Realm to my project but when running I get the following build error from 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

I have tried adding:

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

to my build.gradle in my android{} block, but that does not seem to fix the issue.

I'm adding Realm via

compile 'io.realm:realm-android:0.84.1'

Have tried cleaning/rebuilding etc but still get the issue when trying to run the project. Any ideas?

Orbit
  • 2,985
  • 9
  • 49
  • 106
  • Updating to a recent version of Realm will solve your problem since it doesn't include the annotation processor in the AAR anymore. – Emanuelez May 17 '16 at 19:40

1 Answers1

0

I am using com.jakewharton:butterknife:7.0.1 and io.realm:realm-gradle-plugin:0.90.1. It's working just fine for me.

packagingOptions {
        exclude 'META-INF/services/javax.annotation.processing.Processor'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
    }
mihirjoshi
  • 12,161
  • 7
  • 47
  • 78
  • Running `./gradlew clean assemble` fails with the same exception. Whats odd though is that I'm not even using Butterknife in this project, its not declared as a dependency anywhere. – Orbit May 17 '16 at 18:50
  • Why are you using `io.realm:realm-gradle-plugin` vs `compile 'io.realm:realm-android:0.84.1'`? – Orbit May 20 '16 at 18:04
  • @Orbit see the updated [documentation](https://realm.io/docs/java/latest/#installation) – mihirjoshi May 20 '16 at 19:49