Trying to build a simple example that uses kotlin coroutines in an activity:
lifecycleScope.launch {
val result = httpGet("http://hmkcode-api.appspot.com/rest/api/hello/Android")
textView.setText(result)
}
Can't get rid of error "unresolved reference lifecycleScope"
Relevant part of gradle file:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
dependencies {
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.2'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.2'
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-rx2:1.3.2"
def androidArchVersion = '1.1.1'
implementation "android.arch.lifecycle:viewmodel:$androidArchVersion"
implementation "android.arch.lifecycle:livedata:$androidArchVersion"
annotationProcessor "android.arch.lifecycle:compiler:$androidArchVersion"
testImplementation "android.arch.core:core-testing:$androidArchVersion"
implementation "android.arch.lifecycle:extensions:$androidArchVersion"
}
kotlinOptions {
jvmTarget = '1.8'
apiVersion = '1.3'
languageVersion = '1.3'
}
}
Hilt
in our Activity? – Zeculon