Error: cannot access LifecycleObserver

Make sure you have these added as gradle dependencies :-

 implementation "android.arch.lifecycle:livedata:1.1.1"
 implementation "android.arch.lifecycle:viewmodel:1.1.1"
 implementation "android.arch.lifecycle:extensions:1.1.1"

And also make sure to add google() to your repositories in project level gradle and you are connected to internet !!

Edit

For androidx use :-

def lifecycle_version = "2.0.0"

// ViewModel and LiveData
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"

Tags:

Java

Android