viewModelScope as an extension function of the ViewModel


#1

I try to do the CodeLabs example " Using Kotlin Coroutines in your Android App"
In step 5 they offer to use viewModelScope from the library androidx.lifecycle:lifecycle-viewmodel-ktx:x.x.x, but the Studio cannot resolve it.
That’s the matter and may be I have to add something else?


#2

I don’t think there is any problem with Android Studio.
Have you referred this link?
https://developer.android.com/kotlin/ktx

Is there a lack at setting step ?

repositories {    
  google()
}
dependencies {    
   implementation "androidx.core:core-ktx:1.0.1"
   implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"

#3

I have these dependencies.It doesn’t work


#4

I think you’ll find something here https://github.com/fabioCollini/CoroutinesDemo