本文介绍了Database_Impl不存在-带有Room的android应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Room.我收到此错误(在运行时):

I'm trying to use Room. I get this error (in runtime):

我的BookyDatabase类:

My BookyDatabase class:

@Database(entities = [Book::class, Chapter::class], version = 1)
abstract class BookyDatabase : RoomDatabase() {
    abstract val bookDao: BookDao
    abstract val chapterDao: ChapterDao

    companion object {
        @Volatile
        private var _databaseInstance: BookyDatabase? = null

        fun getDatabase(context: Context): BookyDatabase {
            if (_databaseInstance == null)
                synchronized(BookyDatabase::class.java) {
                    if (_databaseInstance == null)
                        _databaseInstance = Room.databaseBuilder(
                            context.applicationContext,
                            BookyDatabase::class.java,
                            "booky_database"
                        )
                            .fallbackToDestructiveMigration()
                            .build()
                }
            return _databaseInstance!!
        }
    }
}

我不明白怎么了.

推荐答案

BookyDatabase_Impl很可能没有生成...

The BookyDatabase_Impl most likely isn't being generated ...

a)因为缺少注释.

b),因为您没有注释处理器.

b) because you lack an annotation processor.

请参见数据库使用房间"实体定义数据.

这篇关于Database_Impl不存在-带有Room的android应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 09:30