3

ERROR - Realm-Android - I started using Realm for my new project I am getting io.realm.exceptions.RealmMigrationNeededException: Field count is less than expected - expected 5 but was 4... I googled but not found correct solution. can anyone guide me to solve this issue.

  • 1
    It sounds like you changed your Realm model class without adding a schemaVersion/migration to your RealmConfiguration ? – Christian Melchior Jan 31 '17 at 06:02
  • this happens if you add new fields to your existing Realm schema, but you can specify `deleteIfMigrationNeeded()` on your `RealmConfiguration` for during development so you do not need to worry about it – EpicPandaForce Jan 31 '17 at 07:15
  • You might find some help in https://realm.io/docs/java/latest/#migrations – geisshirt Jan 31 '17 at 08:39
  • 1
    I delete primary key from my model... I used **deleteIfMigrationNeeded()** on my RealmConfuguration, but still facing the problem. – chandramouli poreddy Feb 01 '17 at 05:11
  • RealmConfiguration realmConfig = new RealmConfiguration.Builder() .name("example.app") .schemaVersion(0) **.deleteRealmIfMigrationNeeded()** .build(); Added the deleteRealmIfMigrationNeeded() and it works for me. – Rohan Prasad Sep 05 '21 at 12:49

0 Answers0