Nothing is working. Realm Migration [Android 1.2] -


i updated latest version hoping fix issue, has not. using

  realmconfiguration config = new realmconfiguration.builder(this)             .name("myrealm.realm")            .migration(new migration())             .schemaversion(2) // 2             .build();     try {         realm realm = realm.getinstance(config); // automatically run migration if needed         realm.close();     } catch (exception e) {         e.printstacktrace();     }     realm.setdefaultconfiguration(config); 

this code update , add few new objects. here migration

public class migration implements realmmigration { @override public void migrate(final dynamicrealm realm, long oldversion, long newversion) {     // access realm schema in order create, modify or delete classes , fields.     realmschema schema = realm.getschema();     // migrate version 1 version 2     if (oldversion == 1) {         // create new classes         realmobjectschema styleschema = schema.create("savedstyle").addfield("title", string.class).addfield("json", string.class);         realmobjectschema dictschema = schema.create("saveddictionary").addfield("title", string.class).addfield("dictionary", string.class);         realmobjectschema journalschema = schema.create("customjournal").addfield("title", string.class).addfield("json", string.class);         oldversion++;     }     if (oldversion < newversion) {         throw new illegalstateexception(string.format("migration missing v%d v%d", oldversion, newversion));     } } 

}

i error

java.lang.illegalargumentexception: configurations cannot different if used open same file. cause equals() , hashcode() not overridden in migration class: otherclasses.migration 

when trying run standalone without updating previous version even. not sure anymore. need work don't have wipe everyone's data though. thinking making more formal bug report, wanted check if else knows if there solution first. issue occurs whenever try default configuration. works when first open app, crashes when go next activity

i'd error message quite specific, , says should following

public class migration implements realmmigration {     @override     public void migrate(final dynamicrealm realm, long oldversion, long newversion) {         //...     }      @override     public boolean equals(object object) {          return object != null && object instanceof migration;     }      @override     public int hashcode() {          return migration.class.hashcode();     } } 

Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -