https://kotlinlang.org logo
Title
d

Daniele B

08/31/2020, 3:15 PM
Currently just testing multiplatform on Android (not iOS or Web yet). I would like to clarify the configuration of coroutines and ktor. In the KaMPKit,
androidMain
has
org.jetbrains.kotlinx:kotlinx-coroutines-android
, but in my project it seems to compile also without specifying it. However it doesn’t compile if from
androidMain
I remove
io.ktor:ktor-client-android
. Can anyone give an explanation? Is there a reason why Ktor requires the android-specific library and coroutines doesn’t?
r

russhwolf

08/31/2020, 4:11 PM
kotlinx-coroutines-android
just has the Android implementation of
Dispatchers.Main
and some related utilities. If you don't have it you'll probably fail at runtime when you try to access that dispatcher.
d

Daniele B

08/31/2020, 5:39 PM
I am actually using Dispatchers.Main, but it doesn’t fail at runtime