How To Get Lifecycle.coroutinescope With New Androidx.lifecycle:*:2.2.0-alpha01
On 7th May, 2019 androidx.lifecycle:*:2.2.0-alpha01 was released announcing: This release adds new features that adds support for Kotlin coroutines for Lifecycle and LiveData. Det
Solution 1:
I actually spent a couple hours trying to figure this out myself and it turns out it is in a new package that only exists as of the alpha. Add this and you should be good to go.
implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_ver"
Solution 2:
The accepted answers is working, but I'm misused for the first time, so I'm trying to make it clear, the current version of lifecycle
is "2.1.0"
and lifecycleScope
, and ViewModelScope
is not available in this version, to get them use
For ViewModelScope, use androidx.lifecycle:lifecycle-viewmodel-ktx:2.1.0-beta01
or higher.
For LifecycleScope, use androidx.lifecycle:lifecycle-runtime-ktx:2.2.0-alpha01
or higher.
at this time 2.3.0-rc01
is available.
Post a Comment for "How To Get Lifecycle.coroutinescope With New Androidx.lifecycle:*:2.2.0-alpha01"