我正在使用room persistence library
和dagger
房间模块.kt
@Module
class RoomModule {
@Provides
@Singleton
internal fun provideMoviesAppDatabase(application: Application): MoviesAppDatabase {
return Room.databaseBuilder<MoviesAppDatabase>(application, KtMoviesAppDatabase::class.java, Keys.DATABASE_NAME)
.addCallback(object : RoomDatabase.Callback() {
override fun onCreate(db: SupportSQLiteDatabase) {}
override fun onOpen(db: SupportSQLiteDatabase) {}
})
.build()
}
}
kt电影应用程序数据库.kt
@Database(entities = [Movie::class], version = 1)
abstract class KtMoviesAppDatabase : RoomDatabase() {
abstract fun getMovieDAO(): MovieDAO
}
我收到的错误:
{编辑}
我做了些改变
@Module
class RoomModule {
@Provides
@Singleton
internal fun provideMoviesAppDatabase(application: Application): KtMoviesAppDatabase {
return Room.databaseBuilder<KtMoviesAppDatabase>(application, KtMoviesAppDatabase::class.java, Keys.DATABASE_NAME)
.addCallback(object : RoomDatabase.Callback() {
override fun onCreate(db: SupportSQLiteDatabase) {}
override fun onOpen(db: SupportSQLiteDatabase) {}
})
.build()
}
}
我仍然有错误:
Unresolved reference: java
2条答案
按热度按时间2g32fytz1#
非常愚蠢的错误,因为我没有添加适当的依赖项
ep6jt1vc2#
我有这个错误早些时候,我解决了这个问题,通过更新Android Studio,你可以使用这个路径更新(帮助〉检查更新...)