So I'm pretty psyched about the new Realm features added in 0.88 and want to use them in my project. Unfortunately, in 0.88+ it is now neccesary to use a Gradle plugin called realm-android.
I am also using Dagger 1 which requires a code generation step (I am using apt for this). When I apply the realm-android plugin, all compiles fine but I get the dreaded
Module adapter for class could not be loaded
indicating that the compiler has not properly generated the files. If I remove the realm plugin, dagger generates the files correctly. How can I get Realm and Dagger to play nice together with this new plugin mechanism?
build.gradle(project level): (edited for relevance)
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'io.realm:realm-gradle-plugin:0.88.2'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
build.gradle(module level): (edited for relevance)
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
apply plugin: 'com.neenbedankt.android-apt'
android {
compileSdkVersion 23
buildToolsVersion '23.0.2'
dexOptions {
jumboMode = true
}
defaultConfig {
applicationId "xx.xx.xx"
minSdkVersion 15
targetSdkVersion 23
multiDexEnabled true
}
def daggerVersion = '1.2.2'
dependencies {
apt "com.squareup.dagger:dagger-compiler:$daggerVersion"
compile "com.squareup.dagger:dagger:$daggerVersion"
}
Edit 4/2/16
Ok things are getting weird and I wonder if I'm not chasing a ghost here. I noticed that it is not just the addition of the plugin but also the existence of at least two realm models. Having two models X and Y, APT doesn't run for Dagger and I get that same error. Have 0 or 1 models (X OR Y) and it runs without error. I am not using the models in any way nor am I even instantiating a Realm. For a concrete example, here are two data models I'm using that exhibit this behavior.
import io.realm.RealmObject;
import io.realm.annotations.PrimaryKey;
import io.realm.annotations.Required;
public class ContactEmail extends RealmObject {
@PrimaryKey
private String localGuid;
@Required
private String email;
public String getLocalGuid() {
return localGuid;
}
public void setLocalGuid(String localGuid) {
this.localGuid = localGuid;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
}
import io.realm.RealmObject;
import io.realm.annotations.PrimaryKey;
import io.realm.annotations.Required;
public class ContactPhone extends RealmObject {
@PrimaryKey
private String localGuid;
@Required
private String phone;
public String getLocalGuid() {
return localGuid;
}
public void setLocalGuid(String localGuid) {
this.localGuid = localGuid;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
}
realm-android
andcom.neenbedankt.android-apt
? – EpicPandaForce