realm-java: Realm RealmObject is not part of the schema for this Realm
RealmObject is not part of the schema
I have run into this error everytime I make “Clean and rerun app” in Android Studio. Everything worked fine before.
Expected Results
?
Actual Results
FATAL EXCEPTION: main Process: com.lt. PID: 11965 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.lt.com.lt.ui.activities.MainActivity}: io.realm.exceptions.RealmException: class com.lt.model.Order is not part of the schema for this Realm. at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2339) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2413) at android.app.ActivityThread.access$800(ActivityThread.java:155) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1317) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5343) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700) Caused by: io.realm.exceptions.RealmException: class com.lt.model.Order is not part of the schema for this Realm. at io.realm.internal.RealmProxyMediator.getMissingProxyClassException(RealmProxyMediator.java:217) at io.realm.DefaultRealmModuleMediator.getTableName(DefaultRealmModuleMediator.java:72) at io.realm.RealmSchema.getSchemaForClass(RealmSchema.java:235) at io.realm.RealmQuery.<init>(RealmQuery.java:136) at io.realm.RealmQuery.createQuery(RealmQuery.java:85) at io.realm.Realm.where(Realm.java:1026) at com.lt.ui.activities.MainActivity.onCreate(MainActivity.java:85) at android.app.Activity.performCreate(Activity.java:6010) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1129) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2292) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2413) at android.app.ActivityThread.access$800(ActivityThread.java:155) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1317) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5343) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372)
Steps & Code to Reproduce
This is when I start up the application, I need to know if it exists an order unfinished. I have tried these things already.
1.Clean and rebuild project. 2.Deleted generated build files manually. 3.Uninstall app before deploying. 4.I have realm in my project gradle and app gradle. (version 1.1.0) 5.I have tried with Order extending RealmObject and implementing RealmModel. 6.RealmConfiguration has deleteRealmIfMigrationNeeded.
Code Sample
RealmConfiguration realmConfig = new RealmConfiguration
.Builder(getApplicationContext())
.deleteRealmIfMigrationNeeded()
.name("myRealmFile")
.build();
Realm.setDefaultConfiguration(realmConfig);
Realm realm = Realm.getDefaultInstance();
RealmResults<Order> orders = realm.where(Order.class).equalTo("finished", false).findAll();
mHasActiveOrder = orders != null && orders.isValid() && orders.size() > 0;
realm.close();
Version of Realm and tooling
Realm version(s): 1.1.0
Android Studio version: 2.1.2
Which Android version and device: API LVL 24 with Android Moto G with API LVL 22.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 29 (15 by maintainers)
@luna-vulpo that you should use
kapt
instead ofannotationProcessor
, and that you should executekotlin-android
beforerealm-android
Generally it should look like this
My guess goes for that you should disable Instant Run in Android Studio.
If you’re implementing
RealmModel
, then if I know correctly you also need to add the@RealmClass
annotation. However, it’s worth noting that this should work out of the box if you’re extendingRealmObject
, so I think instant run is messing things up.Should be
File -> Settings -> Build Execution Deployment -> Instant Run
and you should make sureEnable instant run
is unticked.I had same problem see this it may helpfull http://stackoverflow.com/questions/42947367/object-is-not-part-of-the-schema-for-this-realm?noredirect=1#comment72992816_42947367
Ah yes, if you don’t add the default proguard, then you need to specify that
keep * extends io.realm.RealmObject
or something like thatI have something similar. Please let me know if i should open new issue or continue here.
This is my setup: Android Studio: 2.1.2 Language: Kotlin 1.0.3 Realm: 1.0.1 Gradle plugin: 2.1.2 Gradle wrapper version: 2.14 Android target API Level: 24 Android compile SDK: 24 Build tool version: 24.0.0 Instant Run: Disabled Testing device running: Android 4.3 Apk is release mode debugable.
First install normal, but the second build will reproduce the error.
If you need more information please let me know.