Unresolved reference async in Kotlin
async
is available inside kotlinx.couroutines
Make sure that you added the dependency in your gradle file:
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.1'
Also make sure that the async is called on a coroutine scrope such as GlobalScope
.
val deferredResult = GlobalScope.async {
}
I see async
function is available in anko
library not Kotlin
library itself. https://github.com/Kotlin/anko
I resolved by adding this dependency in build.gradle compile "org.jetbrains.anko:anko-commons:0.10.1"
as this is not available in Kotlin itself.
I see that async
is deprecated now, library suggests to use doAsync
instead.
doAsync {
val forecastWeather = ForecastRequest("302015").execute()
uiThread {
Log.d("Test", forecastWeather.toString())
}
}