RealmException XX is not part of the schema for this Realm
- 2018.09.27
- Android
現象
- アプリを起動してRealmが起動する操作をすると掲題のエラーで落ちる
条件
- compileSDK:26
- targetSDK:26
- AndroidStudio 3.1.4
- JavaとKotlin混在
原因
- Kotlin移行時に発生
対処方法
- 単にapp/build.gradleの順番直しただけでは直らず
- プロジェクト配下のbuild.gradleも順番修正が必要(※app/build.gradleは世間の逆の順番でないとだめだった。)
Before(app/build.gradle)
1 2 3 4 |
apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'realm-android' |
After(app/build.gradle)
1 2 3 4 |
apply plugin: 'com.android.application' apply plugin: 'realm-android' apply plugin: 'kotlin-android' |
Before(build.gradle)
1 2 3 4 |
buildscript { classpath "io.realm:realm-gradle-plugin:$realm_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" |
After(build.gradle)
1 2 3 4 |
buildscript { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "io.realm:realm-gradle-plugin:$realm_version" |
参考
https://github.com/realm/realm-java/issues/3139
https://minpro.net/realmexception-xx-is-not-part-of-the-schema-for-this-realm
コメントを書く