Realm-java: RealmMigrationNeededException on subsequent build

Created on 8 Jul 2016  路  16Comments  路  Source: realm/realm-java

I got this exception on subsequent build from Android Studio

io.realm.exceptions.RealmMigrationNeededException: The MyUserRealm class is missing from the schema for this Realm.
at io.realm.d.b(MyUserRealmRealmProxy.java:220)
at io.realm.DefaultRealmModuleMediator.b(DefaultRealmModuleMediator.java:71)
at io.realm.r.a(Realm.java:297)
at io.realm.r.b(Realm.java:265)
at io.realm.r.a(Realm.java:244)
at io.realm.s.a(RealmCache.java:126)
at io.realm.r.m(Realm.java:176)

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.

T-Help

All 16 comments

I'm trying with 1.1.0, will give the report soon

@rshah

What the error log indicates is that your class MyUserRealm is missing. Have you somehow eliminated/renamed/given a different name to the class within a migration? I'll look forward your migration code as well. Thanks!

The MyUserRealm class is not new class.
At first the not exist in the phone. Then install and run the app.
Next from Android Studio 'clean the project' then 'rebuild the project' then run the app again.
I can see the exception above (this is the result from 1.0.1, still trying to reproduce with 1.1.0).

@rshah

I'd like to ask you to

  1. Turn off Insta Run
  2. Clean the project
  3. Uninstall the existing app from your test device/emulator with adb
  4. Then rebuild the project

It usually happens somewhere in the build process there remains to be an old residue that blocks your update to be properly installed. If you have a migration step, please let us know too.

Just tried with 1.1.0. Seems no problem.
@stk1m1 I will try as written above for 1.0.1 and 1.1.0.

@rshah

Thanks! I'll be looking forward!

@stk1m1
Tried as written above for 1.0.1 and 1.1.0 for subsequent installation, no exception when running the app.
But i cannot always do adb uninstall to try my changes.

Another observation:

  • followed first installation like your suggestion.
  • change source code by adding dummy variable then run the app again from Android Studio.
  • both 1.0.1 and 1.1.0 will produce RealmMigrationNeededException for subsequent run.

I think it might be not related with realm migration. Because the changes i made did not touch realm at all (just added dummy variable as i mentioned above).

@rshah

Could you send a sample project with which I can reproduce this issue at [email protected]? I've tried to see if I can do the same but have not been able to. Also, I'd highly appreciate if you would experience the same with v1.0.0. Thanks!

I will try to recreate the problem with simple sample.

@stk1m1
I have sent the test project. Please have a look hope you can reproduce it.

@rshah

Thanks! we'll look into it!

@rshah We got your project, but it doesn't compile since some files are missing in the _app_ folder (build.gradle especially). Can you please check and send us a project can be compiled? Thanks a lot!

@beeender
I sent again, please try.

@rshah hello! The project works fine on my machine (comment/uncomment, clean/build)
I am using Android Studio 2.2 Preview 4 .

I saw in your app's build.gradle

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            debuggable true
        }
    }

the minifyEnabled is false but from the stacktrace you shared, the code seems to be obscured . So maybe you could take a look is there any problems with proguard settings when this problem happens?

I see, thank you for confirming. I will try again.

Hope the issue is solved :) I am closing this issue now, let us know if you still need more support.

Was this page helpful?
0 / 5 - 0 ratings