ViewModel in Kotlin: Unresolved Reference

前端 未结 7 1945
离开以前
离开以前 2021-01-07 17:24

I am trying to implement ViewModel in a 100% Kotlin app. Every piece of documentation I can find says I want to use this to get the ViewModel instance:

ViewM         


        
7条回答
  •  悲&欢浪女
    2021-01-07 18:14

    I faced this kind of problem in AndroidStudio 3.0.1 and solved by adding following dependencies in the proper build.gradle:

    implementation "android.arch.lifecycle:extensions:1.1.1"
    annotationProcessor "android.arch.lifecycle:compiler:1.1.1"
    

    version code may be different as AndroidStudio tells you if it differs.

提交回复
热议问题