realm-java: java.lang.NoSuchMethodError: No virtual method add(Lio/realm/Property;)Lio/realm/RealmObjectSchema; in class Lio/realm/RealmObjectSchema

** ERROR**:

Process: ch999.app.UI, PID: 7374
 java.lang.NoSuchMethodError: No virtual method add(Lio/realm/Property;)Lio/realm/RealmObjectSchema; in class Lio/realm/RealmObjectSchema; or its super classes (declaration of 'io.realm.RealmObjectSchema' appears in /data/app/ch999.app.UI-2/split_lib_dependencies_apk.apk:classes36.dex)
                                                                at io.realm.DirectDataRealmProxy.createRealmObjectSchema(DirectDataRealmProxy.java:706)
                                                                at io.realm.BaseRealmModuleMediator.createRealmObjectSchema(BaseRealmModuleMediator.java:58)
                                                                at io.realm.internal.modules.CompositeMediator.createRealmObjectSchema(CompositeMediator.java:66)
                                                                at io.realm.Realm.initializeRealm(Realm.java:440)
                                                                at io.realm.Realm.createAndValidateFromCache(Realm.java:401)
                                                                at io.realm.Realm.createInstance(Realm.java:364)
                                                                at io.realm.RealmCache.doCreateRealmOrGetFromCache(RealmCache.java:346)
                                                                at io.realm.RealmCache.createRealmOrGetFromCache(RealmCache.java:284)
                                                                at io.realm.Realm.getInstance(Realm.java:293)
                                                                at com.ch999.util.BaseInfo.<init>(BaseInfo.java:59)
                                                                at com.ch999.util.BaseInfo.getInstance(BaseInfo.java:64)
                                                                at ch999.app.UI.JiujiApplication.setUp(JiujiApplication.java:80)
                                                                at ch999.app.UI.JiujiApplication.access$000(JiujiApplication.java:46)
                                                                at ch999.app.UI.JiujiApplication$1.run(JiujiApplication.java:58)
                                                                at java.lang.Thread.run(Thread.java:761)
classpath 'com.android.tools.build:gradle:2.3.3'
classpath "io.realm:realm-gradle-plugin:2.3.1"

2.3.2 perfectly normal before, then I through the APT to introduce third-party tools, began to appear error, access to information, I remove the “apply plugin: 'android - APT” and “annotationProcessor” instead, start now has been an error, version of the drop is not normal, be badly in need of help

Version of Realm and tooling

Realm version(s): 3.3.2

Android Studio version: 2.3.3

Which Android version and device:

nexus5 oneplus android 7.1.1

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 19 (9 by maintainers)

Most upvoted comments

This sounds like something you should either be able to fix with a clean/rebuild, or you are using another Realm-based library that is using an outdated version of Realm and relies on outdated internal code.

For example, an old version of Realm-Stetho could easily cause this problem.

@sdaduanbilei As the output says, com.ch999:BaseRes:2.1.6 originally has a dependency to io.realm:realm-android-library:2.3.1 but updated to io.realm:realm-android-library:3.3.2 by the final app.

That means com.ch999:BaseRes:2.1.6 was compiled with io.realm:realm-android-library:2.3.1 and contains generated code for that version.

You can’t mix multiple versions of Realm since generated code does not have a compatibility across versions.

To solve this, you need to recompile com.ch999:BaseRes:2.1.6 with Realm 3.3.2.