Closed falecci closed 8 years ago
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 extending RealmObject
, so I think instant run is messing things up.
Should be File -> Settings -> Build Execution Deployment -> Instant Run
and you should make sure Enable instant run
is unticked.
Hi @falecci
Are you using InstantRun? If yes, please turn it off.
5.I have tried with Order extending RealmObject and implementing RealmModel. no need to do both. please remove
implements RealmModel
.
I have something similar. Please let me know if i should open new issue or continue here.
io.realm.exceptions.RealmMigrationNeededException: The MyUserRealm class is missing from the schema for this Realm.
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.
@rshah can you try updating to 1.1.0? there were some bugfixes between the two regarding the "optional API" and some other things..
@rshah
Actually, I think you should file another issue with detailed crash log. It seems we need more detail on your case to support you. Thanks!
I created new issue here: https://github.com/realm/realm-java/issues/3159
Actually now that you mention it, @falecci and @rshah can you try the following from https://github.com/realm/realm-java/issues/3196 for Kotlin-related schema classes missing:
Try running apply plugin: 'realm-android'
after apply plugin: 'kotlin-android'
(and extensions)
Also try adding to build.gradle
android {
dexOptions {
incremental false
}
}
Hi @falecci
Could you update us on whether the comments above have helped you?
In my case the plugin order already like above, but incremental true
.
And seems after i converted all realm classes to kotlin. The problem did not occured anymore.
I will try incremental false
if the problem appear again
same issue.
io.realm.exceptions.RealmException: class *.*.*.*.RealmAccount is not part of the schema for this Realm.
I've tried running apply plugin: 'realm-android' after apply plugin: 'kotlin-android' (and extensions). And I've set incremental to false and also am running apply plugin: 'realm-android' after apply plugin: 'kotlin-android' (and extensions).
Cleaned and reran many times. Invalidating cache and restarting doesn't help.
Even tried updating to the 1.1.1 snapshot
Actually I've figured out that I needed RealmModules, as half of my realm objects are inside a separate module that we share between two apps. But the weird thing is that that realm objects inside the shared module were added to the schema for the realm, but the realm objects in the main app module were excluded from the schema.
Actually I've figured out that I needed RealmModules, as half of my realm objects are inside a separate module that we share between two apps.
Yes, if you use separate modules and library projects, then you need to expose the models in the library as RealmModules.
@luca992 Did you try to have separate RealmModule
s for libraries?
@kneth yes, that got it working for me.
@luca992 Great to hear. I'll close the issue.
This might also happen when using proguard, as you need to give directives to keep the realm classes to be used
Ah yes, if you don't add the default proguard, then you need to specify that keep * extends io.realm.RealmObject
or something like that
Hi, I ran in same problem. I use: kotlin, dagger2 and realm. So my gradle file looks like this:
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'io.fabric'
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
incremental = false
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
annotationProcessor 'com.google.dagger:dagger-compiler:2.9'
provided 'javax.annotation:jsr250-api:1.0'
}
And using such configuration I can compile the project. But get error that class is not part of the schema for this Realm. What I miss?
@luna-vulpo that you should use kapt
instead of annotationProcessor
, and that you should execute kotlin-android
before realm-android
Working example which uses Realm, Kotlin, Dagger2 and DataBinding https://github.com/zaki50/RealmKotlin_template
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
For the record, I am using realm successfully in a multi-project android build without RealmModule.
But then for some reason the "RealmObject is not part of the schema" problem only surfaced during instrumentation tests.
Subclassing the android application class for instrumentation tests and using a configuration with RealmModules in it solved the problem.
@edman there is a chance you will run into trouble without RealmModules in 3.5.0+.
You can check with 3.5.0-SNAPSHOT
if what I said is true.
@Zhuinden true, I got an error with 3.5.0-SNAPSHOT
and it was resolved with RealmModules.
The exception was more cryptic than the one I had in version 3.4.0
. For the record:
java.lang.AbstractMethodError: abstract method "java.util.Map io.realm.internal.RealmProxyMediator.getExpectedObjectSchemaInfoMap()"
at io.realm.Realm.initializeRealm(Realm.java:468)
at io.realm.Realm.createAndValidateFromCache(Realm.java:423)
at io.realm.Realm.createInstance(Realm.java:371)
at io.realm.RealmCache.doCreateRealmOrGetFromCache(RealmCache.java:346)
at io.realm.RealmCache.createRealmOrGetFromCache(RealmCache.java:284)
at io.realm.Realm.getDefaultInstance(Realm.java:281)
@Zhuinden Thanks man, for solving my problem
@luna-vulpo that you should use kapt instead of annotationProcessor, and that you should execute kotlin-android before realm-android
Generally it should look like this
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'realm-android'
Even after changing in above order I'm getting same issue @Zhuinden
@Vaishnavi-optisol Unfortunately i do not know enough about your project to tell you what's wrong
The order above generally worked for everyone
You can try https://realm.io/docs/java/latest/#how-do-i-customize-dependecies-defined-by-the-realm-gradle-plugin
Check your Class Definition Make sure you have extended your class to RealmObject. and don't implement RealmModule
RealmObject is not part of the schema
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
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.