1
私の問題を解決することを望む最新のバージョンに更新しましたが、それはありません。私は使用しています何も動作していません。レルムマイグレーション[Android 1.2]
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);
このコードはいくつかの新しいオブジェクトを更新して追加します。ここだけでも、以前のバージョンから更新することなく、それをスタンドアロンで実行しようとすると、私はエラーに
java.lang.IllegalArgumentException: Configurations cannot be different if used to open the same file. The most likely cause is that equals() and hashCode() are not overridden in the migration class: otherClasses.Migration
を取得し、私の移行
public class Migration implements RealmMigration {
@Override
public void migrate(final DynamicRealm realm, long oldVersion, long newVersion) {
// Access the Realm schema in order to create, modify or delete classes and their fields.
RealmSchema schema = realm.getSchema();
// Migrate from version 1 to version 2
if (oldVersion == 1) {
// Create a 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 from v%d to v%d", oldVersion, newVersion));
}
}
}
です。もう何をすべきかわからない。本当にそれが動作する必要があるので、私はすべてのデータを消去する必要はありません。より正式なバグレポートを作成することを考えていますが、解決策が最初にあるかどうか誰かが知っているかどうかを確認したいと考えました。この問題は、デフォルト設定を取得しようとするたびに発生します。それは私が最初にアプリを開いたときに通常動作しますが、私は、私は、エラーメッセージは非常に特定であると言うだろう次のアクティビティ
Iを行う必要がありますと言いますあなたはおそらくこれを見たことがありますが、あなたは決して返事に気にしませんでした。私はその質問が**重要ではないと思う。 – EpicPandaForce