Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not find io.realm.ClimbingModuleMediator

I'm trying to create a library RealmModuleso I can share a schema between my wear and mobile modules. I'm creating the module like this

@RealmModule(library = true, allClasses = true)
public class ClimbingModule {
}

There's only one RealmObject, which I've placed in the same library module and created like this:

public class Climb extends RealmObject {
    private int grade;
    private int type;
    @Required private Date date;
    @PrimaryKey private String id;

    // getters and setters
    ...
}

And it's used in this configuration:

RealmConfiguration config = new RealmConfiguration.Builder(context)
                .deleteRealmIfMigrationNeeded()
                .modules(new ClimbingModule())
                .build();
Realm.setDefaultConfiguration(config);

The error I'm getting is :

java.lang.RuntimeException: Unable to create application com.android.tools.fd.runtime.BootstrapApplication: io.realm.exceptions.RealmException: Could not find io.realm.ClimbingModuleMediator
                                                                                            at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4715)
                                                                                            at android.app.ActivityThread.-wrap1(ActivityThread.java)
                                                                                            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
                                                                                            at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                            at android.os.Looper.loop(Looper.java:148)
                                                                                            at android.app.ActivityThread.main(ActivityThread.java:5422)
                                                                                            at java.lang.reflect.Method.invoke(Native Method)
                                                                                            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                                            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                                                                                         Caused by: io.realm.exceptions.RealmException: Could not find io.realm.ClimbingModuleMediator
                                                                                            at io.realm.RealmConfiguration.getModuleMediator(RealmConfiguration.java:293)
                                                                                            at io.realm.RealmConfiguration.createSchemaMediator(RealmConfiguration.java:267)
                                                                                            at io.realm.RealmConfiguration.<init>(RealmConfiguration.java:111)
                                                                                            at io.realm.RealmConfiguration.<init>(RealmConfiguration.java:63)
                                                                                            at io.realm.RealmConfiguration$Builder.build(RealmConfiguration.java:649)
                                                                                            at com.example.mysynclibrary.Shared.initRealm(Shared.java:34)
                                                                                            at com.example.grant.wearableclimbtracker.MyApplication.onCreate(MyApplication.java:20)
                                                                                            at com.android.tools.fd.runtime.BootstrapApplication.onCreate(BootstrapApplication.java:370)
                                                                                            at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1013)
                                                                                            at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4712)
                                                                                            at android.app.ActivityThread.-wrap1(ActivityThread.java) 
                                                                                            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405) 
                                                                                            at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                            at android.os.Looper.loop(Looper.java:148) 
                                                                                            at android.app.ActivityThread.main(ActivityThread.java:5422) 
                                                                                            at java.lang.reflect.Method.invoke(Native Method) 
                                                                                            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                                                                            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
                                                                                         Caused by: java.lang.ClassNotFoundException: io.realm.ClimbingModuleMediator
                                                                                            at java.lang.Class.classForName(Native Method)
                                                                                            at java.lang.Class.forName(Class.java:324)
                                                                                            at java.lang.Class.forName(Class.java:285)
                                                                                            at io.realm.RealmConfiguration.getModuleMediator(RealmConfiguration.java:288)
                                                                                            at io.realm.RealmConfiguration.createSchemaMediator(RealmConfiguration.java:267) 
                                                                                            at io.realm.RealmConfiguration.<init>(RealmConfiguration.java:111) 
                                                                                            at io.realm.RealmConfiguration.<init>(RealmConfiguration.java:63) 
                                                                                            at io.realm.RealmConfiguration$Builder.build(RealmConfiguration.java:649) 
                                                                                            at com.example.mysynclibrary.Shared.initRealm(Shared.java:34) 
                                                                                            at com.example.grant.wearableclimbtracker.MyApplication.onCreate(MyApplication.java:20) 
                                                                                            at com.android.tools.fd.runtime.BootstrapApplication.onCreate(BootstrapApplication.java:370) 
                                                                                            at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1013) 
                                                                                            at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4712) 
                                                                                            at android.app.ActivityThread.-wrap1(ActivityThread.java) 
                                                                                            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405) 
                                                                                            at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                            at android.os.Looper.loop(Looper.java:148) 
                                                                                            at android.app.ActivityThread.main(ActivityThread.java:5422) 
                                                                                            at java.lang.reflect.Method.invoke(Native Method) 
                                                                                            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                                                                            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
                                                                                         Caused by: java.lang.ClassNotFoundException: Didn't find class "io.realm.ClimbingModuleMediator" on path: DexPathList[[dex file "/data/data/com.example.grant.wearableclimbtracker/files/instant-run/dex/slice-support-annotations-24.0.0_8ed1f58ead6d248c8a4f50bb1897cc60a8d93971-classes.dex", dex file "/data/data/com.example.grant.wearableclimbtracker/files/instant-run/dex/slice-stetho-1.3.1_3739d2a1ecc8680bba36444b965da940ae04a19b-classes.dex", dex file "/data/data/com.example.grant.wearableclimbtracker/files/instant-run/dex/slice-slice_9-classes.dex", dex file "/data/data/com.example.grant.wearableclimbtracker/files/instant-run/dex/slice-slice_8-classes.dex", dex file "/data/data/com.example.grant.wearableclimbtracker/files/instant-run/dex/slice-slice_7-classes.dex", dex file "/data/data/com.example.grant.wearableclimbtracker/files/instant-run/dex/slice-slice_6-classes.dex", dex file "/data/data/com.example.grant.wearableclimbtracker/files/instant-run/dex/slice-slice_5-classes.dex", dex file "/data/data/com.example.grant.wearableclimbtracker/files/instant-run/dex/slice-slice_4-classes.dex", dex file "/data/data/com.example.grant.wearableclimbtracker/files/instant-run/dex/slice-slice_3-classes.dex", dex file "/data/data/com.example.grant.wearableclimbtracker/files/instant-run/dex/slice-slice_2-classes.dex", dex file "/data/data/com.example.grant.wearableclimbtracker/files/instant-run/dex/slice-slice_1-classes.dex", dex file "/data/data/com.example.grant.wearableclimbtracker/files/instant-run/dex/slice-slice_0-classes.dex", dex file "/data/data/com.example.grant.wearableclimbtracker/files/instant-run/dex/slice-realm-annotations-1.1.0_6d467512d704956e369a7713fcd76becefc3e018-classes.dex", dex file "/data/data/com.example.grant.wearableclimbtracker/files/instant-run/dex/slice-jsr305-2.0.1_fa7c5ea253e798c2471f648fc357192a6a638816-classes.dex", dex file "/data/data/com.example.grant.wearableclimbtracker/files/instant-run/dex/slice-io.realm-realm-android-library-1.1.0_99e6e7dc6894989e0af3ce27b39ee

Where is io.realm.ClimbingModuleMediator supposed to get created?

I'm not using ProGuard or Multidex, which are the only other culprits I could find for this error on SO.

Thanks in advance!

like image 224
chanban Avatar asked Oct 13 '16 16:10

chanban


3 Answers

In your project's .gradle file,

apply plugin: 'realm-android'

The line above should be after the line in Kotlin

apply plugin: 'kotlin-android'

or in JAVA

apply plugin: 'com.android.library'
like image 108
Allen Avatar answered Nov 02 '22 06:11

Allen


You should disable Instant Run and possibly do a clean rebuild.

like image 33
EpicPandaForce Avatar answered Nov 02 '22 05:11

EpicPandaForce


Make sure that you apply the plugin into your module

apply plugin: 'realm-android'
like image 21
Andres David serrano Avatar answered Nov 02 '22 04:11

Andres David serrano