How to get lifecycle.coroutineScope with new androidx.lifecycle:*:2.2.0-alpha01

前端 未结 2 676
你的背包
你的背包 2021-02-18 15:09

On 7th May, 2019 androidx.lifecycle:*:2.2.0-alpha01 was released announcing:

This release adds new features that adds support for Kotlin coro

2条回答
  •  伪装坚强ぢ
    2021-02-18 15:31

    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.

提交回复
热议问题