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

前端 未结 24 1757
长发绾君心
长发绾君心 2020-12-01 09:05

I\'m converting a project to Kotlin and I\'m trying to make my model (which is also my entity) a data class I intend to use Moshi to convert the JSON responses from the API<

24条回答
  •  粉色の甜心
    2020-12-01 09:24

    What worked for me:

    @Entity(tableName = "movies")
    data class MovieKt(
        @PrimaryKey
        var id : Int? = 0,
        var title: String? = "",
        var overview: String? = "",
        var poster_path: String? = "",
        var backdrop_path: String? = "",
        var release_date: String? = "",
        var vote_average: Double? = 0.0,
        var isFavorite: Int? = 0
    )
    

提交回复
热议问题