3

I'm trying to use both Realm.io and Dagger in my android app, but I seem to be getting conflict issues with the META-INF/services/javax.annotation.processing.Processor file.

I've tried adding the following to my build.gradle file:

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

and also tried it with exclude, but I get errors like the annotation processors aren't being run in either project.

The error I keep running into is the standard Module adapter for class could not be loaded..

What I think is happening is that since both AnnotationProcessors aren't being kept, the processors of one or the other package won't happen, but I could be way off.

rharter
  • 2,495
  • 18
  • 34

1 Answers1

2

Your AnnotationProcessors should not be in your compile dependency scope, they should either be in provided or, if you use android-apt, apt.

It doesn't look like Realm separates out their annotation processor like they should, so that one will need to stay in your compile classpath, but the dagger compiler can move to provided.

This would end up looking something like this:

compile 'com.squareup.dagger:dagger:1.2.2'
provided 'com.squareup.dagger:dagger-compiler:1.2.2'

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

The provided (or apt) scope makes the dependencies available to your compiler, but doesn't include them in the final product, which they aren't needed for. The conflict you're running into is in the dex process, but in those scopes these classes will never get that far.

This also has the added benefit of trimming down the size of your final APK.

rharter
  • 2,495
  • 18
  • 34