It's because of proguard obfuscation. Add your database models to proguard-rules.pro
file to prevent them from being obfuscated during the build. For example, you have a class called ContactModel.java for your contacts table like so:
@Entity(tableName = "contacts")
public class ContactModel {
@PrimaryKey(autoGenerate = true)
public int id;
@ColumnInfo(name = "name")
public String name;
@ColumnInfo(name = "number")
public String number;
}
And the address of the class is com.example.myapp.model.ContactModel.java
. You should add a rule to proguard-rules.pro
like this:
-keep public class com.example.myapp.model.ContactModel
If you have a lot of classes and you don't want to add them one by one you just need to add all of them to one package; for example model
, and then put *
instead of the class name at the end of the address like so:
-keep public class com.example.myapp.model.*