Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Cannot access android.arch.lifecycle.ViewModelStoreOwner" in android studio 3.2

I have recently upgraded my android studio to version 3.2, and since everywhere I try to access fragment/activity attributes from my ViewModel classes, I get this "Cannot access android.arch.lifecycle.ViewModelStoreOwner" message:

example of the error message

It does not affect compilation, but this annoying message pops in a lot of class.

Any ideas?

PS: I have already tried "Invalidate caches and restart" several times

like image 652
jdbs Avatar asked Oct 01 '18 13:10

jdbs


2 Answers

Just got the same problem after update, this helped: Add this line to your module’s build.gradle script:

dependencies {
    ...
    implementation 'android.arch.lifecycle:extensions:1.1.1'
}

Found it here: Adding Components to your Project

like image 110
Che Avatar answered Nov 11 '22 00:11

Che


I have faced the same issue and I resolved this issue by updating android support libraries in build.gradle file.

I would recommend updating your android support libraries to 27.1.1 or newer. No need to add this :

implementation 'android.arch.lifecycle:extensions:1.1.1'
like image 32
Minkoo Avatar answered Nov 10 '22 23:11

Minkoo