Room Persistence: Error:Entities and Pojos must have a usable public constructor

It’s not a problem in your case, but for others, this error can occur if you have @Ignore params in your primary constructor, i.e. Room expects to have either:

  • parameterless constructor or
  • constructor with all fields not marked with @Ignore

for example:

@Entity(tableName = "movies")
data class MovieKt(
    @PrimaryKey
    var id : Int,
    var title: String,
    @Ignore var overview: String) 

will not work. This will:

@Entity(tableName = "movies")
data class MovieKt(
    @PrimaryKey
    var id : Int,
    var title: String) 

Leave a Comment