Cannot resolve symbol ViewModelProviders
android.arch.lifecycle:extensions:1.1.1
definitely has android.arch.lifecycle.ViewModelProviders
. You can see it in Android Studio, if you open the "External Libraries" portion of the project tree and examine the library contents:
Some possible reasons for not finding the import
include:
You have
implementation "android.arch.lifecycle:extensions:1.1.1"
in the wrong place (it should be in thedependencies
closure of the module'sbuild.gradle
file, such asapp/build.gradle
)You did not sync Android Studio with the Gradle build files (you are normally prompted to do this, but you can do it manually from File > Sync Project with Gradle Files from the Android Studio main menu)
You do not need both lifecycle:extensions
and lifecycle:viewmodel
in your build.gradle file, remove
implementation "android.arch.lifecycle:viewmodel:1.1.1"
and it should be fine now. Also, you may want to migrate to AndroidX and use the 2.0.0 versions of the library.