Getting io.realm.exceptions.RealmMigrationNeededException randomly
See original GitHub issueThis crash happens randomly when getting Realm configuration and does not happen during the actual migration part.
Realm Configuration Code
private static int realmDBVersion = 10;
if(mRealmConfiguration==null)
{
mRealmConfiguration = new RealmConfiguration.Builder()
.name(dbFileName + ".realm")
.encryptionKey(password)
.schemaVersion(realmDBVersion)
.migration(new MyRealmMigration())
.build();
}
return mRealmConfiguration;
MyRealmMigration code
RealmSchema schema = realm.getSchema();
if(oldVersion ==9){
schema.create("CodeTypeItemAuxiliary");
RealmObjectSchema formMappingAreaSchema = schema.get("FormMappingArea");
RealmObjectSchema codeTypeItem = schema.get("CodeTypeItem");
RealmObjectSchema codeTypeItemAuxiliary = schema.get("CodeTypeItemAuxiliary");
codeTypeItemAuxiliary
.addField("objectId",int.class, FieldAttribute.PRIMARY_KEY)
.addField("codeTypeItemId", String.class)
.addField("formFieldAttribute", String.class)
.addField("value", String.class);
formMappingAreaSchema.addField("formFieldAttribute", String.class);
codeTypeItem.addRealmListField("codeTypeItemAuxiliaryList",codeTypeItemAuxiliary);
oldVersion++;
}
Version of Realm and tooling
Realm version(s): 3.3.1
Realm sync feature enabled: no
Android Studio version: 2.3.3
Which Android version and device: Samsung S7
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
android - Can't avoid io.realm.exceptions ... - Stack Overflow
exceptions.RealmMigrationNeededException: Migration is required due to the following errors: - Primary Key for class 'NoteModel' has been added.
Read more >TaskTracker Android tutorial fails after schema change
TaskActivity}: io.realm.exceptions.RealmMigrationNeededException: Migration is required due to the following errors: - Property 'Task.
Read more >RealmTests.java example - Javatips.net
Random ; import java.util. ... RealmMigrationNeededException; import io.realm.exceptions. ... j++) { test_char = test_char_old + chars_array.get(random.
Read more >Integrating Realm Database in an Android Application - Auth0
Getting Started · buildscript { repositories { jcenter() } dependencies { classpath "io.realm:realm-gradle-plugin:3.1.4" } } · apply plugin: ' ...
Read more >Realm数据库- Android技巧 - 积木
RealmMigration; import io.realm.exceptions.RealmMigrationNeededException; import java.io.File; import java.util.Random; import android.content.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

If you did all this config initialization in
Application.onCreate()then this problem would not be possible.Closing due to no response. @rahulmenezes feel free to reopen if you have new information.