Reputation: 1567
While setting up realm in project by following this documentation.
below is my project level gradle :
buildscript {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
// Realm
classpath "io.realm:realm-gradle-plugin:1.2.0"
}
app level gradle :
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'realm-android'
dependencies {
final DAGGER_VERSION = '2.7'
....
def daggerCompiler = "com.google.dagger:dagger-compiler:$DAGGER_VERSION"
annotationProcessor daggerCompiler
testAnnotationProcessor daggerCompiler
androidTestAnnotationProcessor daggerCompiler
compile "com.google.dagger:dagger:$DAGGER_VERSION"
provided 'org.glassfish:javax.annotation:10.0-b28' //Required by Dagger2
}
Upvotes: 3
Views: 967
Reputation: 9241
This answer is based off of Vasiliy's previous answer. I'm promoting my comments to his/her answer to make the solution that worked for me more visible.
As Vasiliy suggested, reversing these lines:
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'realm-android'
to
apply plugin: 'realm-android'
apply plugin: 'com.neenbedankt.android-apt'
allowed the reporting of an underlying Realm error that was preventing Dagger from generating my application component class (in my case, a breaking change introduced in Realm 2.x).
After addressing this issue, with the reordered apply plugin
lines I received this error:
java.lang.IllegalArgumentException: XXX is not part of the schema for this Realm
By reordering the plugins, Realm annotations are not being processed as needed. So the plugin lines must then be restored to:
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'realm-android'
Upvotes: 0
Reputation: 16228
This is one of the most serious downsides of Dagger 2 - its error reporting is terrible. I regularly observe these kind of errors, and you can't understand a thing from that message.
The problem is that Dagger 2 pre-processor runs before javac
compilation, and if the code couldn't be processed, then pre-processor fails without generating components implementations. To my best knowledge, the pre-processor doesn't report what error caused the failure. Then, when javac
compilation executed it fails because it can't find the generated file, but it doesn't proceed to compilation of other files, therefore the only error you see is about missing Dagger component.
What I do in such cases is three stepped solution:
javac
comilation will show you the actual errors.I know nothing about Realm, but since I see it uses its own plugin, you could start by changing the order of plugins appliance in build.gradle
. Switch these lines:
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'realm-android'
Upvotes: 2