【发布时间】:2020-03-27 10:27:21
【问题描述】:
我正在尝试在我的应用程序中将这两个构建器用于协程,但在我的 ViewModel 中我无法导入它们或它们不会弹出。
这些是我的依赖项:
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0-rc02"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.2'
在我的 ViewModel 中
class MainViewModel(): ViewModel() {
init{
viewModelScope ----> does not work , marked in red
val data = liveData {} ----> does not work, marked in red
}
}
我用无效的缓存重建、清理和重新启动,但我不能使用它们
【问题讨论】:
标签: android kotlin mvvm kotlin-coroutines