Unable to solve error: Type of the parameter must be a class annotated with @Entity or a collection/array of it

please check what's the error. Thanks in advance.

interface FavDishDao {

    suspend fun insertFavDishDetails(favDish: FavDish)

    fun getAllDishesList(): Flow<List<FavDish>>

    suspend fun updateFavDishDetails(favDish: FavDish)

    @Query("SELECT * FROM FAV_DISHES_TABLE WHERE favorite_dish = 1")
    fun getFavoriteDishesList(): Flow<List<FavDish>>

2 answers

  • answered 2021-06-10 11:20 Praveen

    You have to annotate your data class FavDish with @Entity(tableName="FAV_DISHES_TABLE") for creating a table for this data class in your Room database.

  • answered 2021-06-10 11:58 Tushar Verma

    If You have annotated your entity and instantiated database properly then this is actually the same problem I faced just go to your build.gradle(app) file and there you could see warnings in you dependencies(highlighted in yellow). Press ctrl+alt+shift+s(basically the open option) then go to dependencies(as shown in the image below) and then one by one on all your dependencies check whether there is an update variable option available in the details part if yes click on that. Once you are done with all of them click apply after that click ok and that would sync your gradle.

    Now try to run your app.

    PS:-As others have suggested try to be a little more descriptive with your question the next time.

    enter image description here