I am following the "Guide to app architecture" (Jetpack) and it cannot resolve references as below.
I already added the libraries:
build.gradle (Module: app):
def lifecycle_version = "2.0.0"
implementation "androidx.lifecycle:lifecycle-runtime:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
build.gradle (Project: ProjectName)
allprojects {
repositories {
google()
jcenter()
}
}
What is missing to work?
There's two issues:
1) ViewModel-SavedState is a separate artifact that needs to be included:
def viewmodel_savedstate_version = "1.0.0-alpha02"
implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:1.0.0-alpha01"
2) As per the 1.0.0-alpha02 release notes:
SavedStateVMFactory
is renamed toSavedStateViewModelFactory
.
So make sure you're using SavedStateViewModelFactory
in any place where you would otherwise have used SavedStateVMFactory
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With