111757
(Стефан Јовановић)
1
I’m using your Sync library for my Kotlin Multiplatform project for Android and iOS. I’ve been able to authenticate and create the user/collection before. Suddenly when I try to configure the realm, before signing in and interacting with the database, I get this error without any detailed information. It’s not the first time to work with Mongodb Device sync SDK, but this time I don’t see anything strange in the project logs, nor on the logs on MongoDB Atlas? Strange…
java.lang.IllegalStateException: [RLM_ERR_SCHEMA_VALIDATION_FAILED]: Schema validation failed due to the following errors:
Stacktrace:
System.out com.stevdza_san.codingquizzie I at io.realm.kotlin.internal.ConfigurationImpl$openRealm$2.invoke(ConfigurationImpl.kt:115)
System.out com.stevdza_san.codingquizzie I at io.realm.kotlin.internal.ConfigurationImpl$openRealm$2.invoke(ConfigurationImpl.kt:114)
System.out com.stevdza_san.codingquizzie I at io.realm.kotlin.internal.ConfigurationImpl.openRealm$suspendImpl(ConfigurationImpl.kt:114)
System.out com.stevdza_san.codingquizzie I at io.realm.kotlin.internal.ConfigurationImpl.openRealm(Unknown Source:0)
System.out com.stevdza_san.codingquizzie I at io.realm.kotlin.mongodb.internal.SyncConfigurationImpl.openRealm(SyncConfigurationImpl.kt:138)
111757
(Стефан Јовановић)
2
I’ve found the reason. Here’s my structure:
open class Quiz: RealmObject {
...
var _id: ObjectId = ObjectId()
var questions: RealmList<QuizQuestion> = realmListOf()
}
open class QuizQuestion: EmbeddedRealmObject {
...
var codeExample: CodeExample = CodeExample()
}
open class CodeExample: EmbeddedRealmObject {
...
}
To fix the issue, I had to add codeExample
as nullable type, with a null as a default value. Then the error disappeared. Hope it helps someone. 
open class QuizQuestion: EmbeddedRealmObject {
...
var codeExample: CodeExample? = null
}
1 Like