Peter Hsu
08/15/2020, 7:33 AMCoroutineScope(Dispatchers.Default).launch {
...
}
iOS output when calling from the main thread:
kotlin.IllegalStateException: There is no event loop. Use runBlocking { ... } to start one.
I'm running on iOS simulator, would that be the issue?
I suspected a dependency versioning issue, so I am forcing coroutines version to be 1.3.5-native-mt via gradle as it seemed to be being force back to 1.3.5 without it, using the following in my root gradle:
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == "org.jetbrains.kotlinx" &&
details.requested.name == "kotlinx-coroutines-core-common") {
details.useVersion("$coroutinesVer")
}
if (details.requested.group == "org.jetbrains.kotlinx" &&
details.requested.name == "kotlinx-coroutines-core") {
details.useVersion("$coroutinesVer")
}
}
}
}
and my dependencies tasks indicate the proper libs are being pulled in now.
I'm really confused why I'm getting this error message. It was my understand that 1.3.5-native-mt utilizes a single background thread for Dispatchers.Default.John O'Reilly
08/15/2020, 8:18 AMnative-nt
version is being picked up as a transitive dependency.....running ./gradlew :common:dependencies
should show if that's the case (substitute with name of whatever your common module is)John O'Reilly
08/15/2020, 8:25 AMisForce
...or I think strictly
is preferred now) in gradle to force use of particular version ....have example in https://github.com/joreilly/BikeShare/blob/master/common/build.gradle.ktsJohn O'Reilly
08/15/2020, 8:27 AMPeter Hsu
08/15/2020, 3:57 PMAndrea Prearo
08/17/2020, 3:26 PMDispatchers.Main
for iOS may be missing a run loop. This thread has some useful information about the issue: https://github.com/Kotlin/kotlinx.coroutines/issues/470.