Cannot create an instance of class ViewModel kotlin

前端 未结 7 1845
礼貌的吻别
礼貌的吻别 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:39

    remove kapt "xxxx.xxx." if you still use that in you gradle.build since it'e been deprecated and add

    apply plugin: 'kotlin-kapt'
    

    at the end of your gradle.build for the app module. that fixed my problem in android studio 3.1

提交回复
热议问题