error: Entity class must be annotated with @Entity

I solved it by changing my @Database's argument (RoomDatabase class), I didn't realize and put my DAO where should be my Entity.

In my case:

@Database(entities = [WordDao::class],version = 1)

changed to:

@Database(entities = [WordEntity::class],version = 1)

So, when somebody gets this error, maybe should to check not only where the entity is declared but too where it is used.


As it said in the first comment, you are trying to insert and delete HistorySongDao objects instead of HistorySong, your code will become:

@Dao
 interface HistorySongDao {

       @Delete
       fun deleteSong(vararg historySong: HistorySong)

       @Insert(onConflict = OnConflictStrategy.REPLACE)
        fun insert(vararg historySong: HistorySong)

       @Query("SELECT * FROM HistorySong")
        fun loadAllSongs(): Array<HistorySong>

       @Query("SELECT * FROM HistorySong WHERE songId = :mId")
        fun findById(mId: Int): HistorySong

       @Query("SELECT * FROM HistorySong WHERE is_favoutire = :getFavourite ")
        fun getFavourite(getFavourite : Boolean) : Array<HistorySong>

       @Update
       fun updateUsers(vararg historySong: HistorySong)
}