Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unresolved reference: SavedStateVMFactory

I am following the "Guide to app architecture" (Jetpack) and it cannot resolve references as below.

Unresolved reference: SavedStateVMFactory

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?

like image 885
Ian Grinkraut Avatar asked Jul 05 '19 19:07

Ian Grinkraut


1 Answers

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 to SavedStateViewModelFactory.

So make sure you're using SavedStateViewModelFactory in any place where you would otherwise have used SavedStateVMFactory.

like image 195
ianhanniballake Avatar answered Nov 12 '22 05:11

ianhanniballake