Reputation: 43
I have the app that has been production released
Realm version I'm currently using is 1.1.0
After adding Firebase crash reporting I started to get strange errors:
io.realm.exceptions.RealmMigrationNeededException: The MedicineSchedulerItem class is missing from the schema for this Realm.
Unable to start receiver BootReceiver: io.realm.exceptions.RealmMigrationNeededException: The MedicineSchedulerItem class is missing from the schema for this Realm.
Realm migration procedure
@Override
public void migrate(DynamicRealm realm, long oldVersion, long newVersion) {
RealmSchema schema = realm.getSchema();
if (oldVersion == 0) {
schema
.get("DoctorVisit")
.addField("docType", String.class);
oldVersion++;
}
if (oldVersion == 1) {
schema
.create("Message")
.addField("id", String.class, FieldAttribute.PRIMARY_KEY)
.addField("text_ru", String.class)
.addField("text_en", String.class)
.addField("text_ua", String.class)
.addField("title_ru", String.class)
.addField("title_en", String.class)
.addField("title_ua", String.class)
.addField("date", long.class)
.addField("download", int.class)
.addField("isVisible", Boolean.class)
.addField("isRead", Boolean.class);
oldVersion++;
}
if (oldVersion == 2) {
schema.get("DoctorVisit")
.addField("useNotifications", boolean.class);
schema.create("MedicineSchedulerItem")
.addField("id", String.class, FieldAttribute.PRIMARY_KEY)
.addField("parentId", String.class)
.addField("masterId", String.class)
.addField("dosage", float.class)
.addField("time", long.class)
.addField("alarmId", int.class)
.addField("isVisible", boolean.class);
schema
.create("MedicineCourse")
.addField("id", String.class, FieldAttribute.PRIMARY_KEY)
.addField("userId", String.class)
.addField("profileId", String.class)
.addField("comment", String.class)
.addField("isVisible", boolean.class)
.addField("updateTime", long.class)
.addField("title", String.class)
.addField("manufacturingForm", int.class)
.addField("dosage", float.class)
.addField("measurementUnit", int.class)
.addField("dateStart", long.class)
.addField("duration", int.class)
.addField("takingIntervalDays", int.class)
.addField("takingTime", long.class)
.addField("takingTimeType", long.class)
.addField("useNotifications", boolean.class)
.addRealmObjectField("medicine", schema.get("Medicine"))
.addRealmListField("scheduler", schema.get("MedicineSchedulerItem"))
.addRealmListField("dayScheduler", schema.get("MedicineSchedulerItem"));
oldVersion++;
}
}
Most of devices work properly, migration process last the way it should. But in some rare cases I get the error I've mentioned above.
I use 'Realm.getDefaultInstance()' for getting realm instance, startup initialization:
RealmConfiguration realmConfiguration = new RealmConfiguration.Builder(this)
.name(Realm.DEFAULT_REALM_NAME)
.schemaVersion(3)
.migration(new ProjectRealmMigration())
.build();
Realm.setDefaultConfiguration(realmConfiguration);
Upvotes: 1
Views: 931
Reputation: 19273
Check if your RealmObject class has any non-nullable values (without the ?), if so, be sure to set the FieldAttribute.REQUIRED
to those properties.
I had the same issue and somehow when using kotlin data types, for some devices it works and for others it doesn't (as you mention. So you need to specify the non-nullability.
Upvotes: 1
Reputation: 1054
This is not a multiprocess issue. This error simply appears because you updated your Realm Objects Interface (Realm Schema). If you don't want to use migrations to fix the problem, you can fix it by going to AVD Manager, selecting the virtual device you use, click the arrow on right and click "wipe data".
NOTE: this will delete any other data you have on this device so you might consider creating new virtual device instead.
Upvotes: 0