Cannot create an instance of class ViewModel kotlin

前端 未结 7 1860
礼貌的吻别
礼貌的吻别 2021-01-18 05:39

Here is my code

class BookmarkViewModel(app: Application) : AndroidViewModel(app) {

    private val dao = BookmarkDb.get(app).bookmarkDao()

    companion o         


        
7条回答
  •  悲&欢浪女
    2021-01-18 06:41

    As somebody said here:

    Android room persistent: AppDatabase_Impl does not exist

    the solution was:

    implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version" kapt "androidx.lifecycle:lifecycle-compiler:$lifecycle_version"

    implementation "androidx.room:room-runtime:$roomVersion"
    kapt "androidx.room:room-compiler:$roomVersion"
    
    
    implementation "androidx.paging:paging-runtime:$paging_version"
    

提交回复
热议问题