I am trying to use coroutines in a Kotlin native p...
# kotlin-native
p
I am trying to use coroutines in a Kotlin native project and am having trouble with the dependency spec. I’m using
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-native:1.3.11"
which Gradle is not happy with. What is the right version to use? And is Maven Central the correct repository to use?
Probing I find that Maven Central has both 1.0.1 and 1.1.0-alpha versions but neither is doing the trick for me. 😞
g
Did you add repo with native dependencies and enable Gradle metadata?
p
Yes,
Copy code
repositories {
    mavenCentral()
    maven { url ’<https://dl.bintray.com/jetbrains/kotlin-native-dependencies>' }
}
and I added the Gradle metadata to the settings.gradle file.
enableFeaturePreview('GRADLE_METADATA')
m
Do you use Gradle 4.7? If not you have to select explicit version, see variants here: https://jcenter.bintray.com/org/jetbrains/kotlinx/
p
I tried with both 4.7 and 4.10.2 to no avail. A working project example URL would be good.
Man oh man, was solving this problem painful. Somehow I missed that selecting the explicit version meant appending “_debug_macos_x64” to “kotlinx-coroutines-core-native”. 🙂
And it gets worse. 😞 Having to downgrade Gradle to 4.7 causes Issue 564 (https://github.com/Kotlin/kotlinx.coroutines/issues/564) to rear it’s ugly head since I use other libraries that were built with Gradle > 4.7. Yuck. Any chance Issue 564 gets fixed in 1.3.20 ? @olonho
m
What happens if DISABLE metadata and use explicit versions?
p
In that case the other two native library dependencies do not get resolved. I have to abandon coroutines for now until Issue 564 gets resolved and find another solution. This will likely be an easier path.
m
Yes, in that case you have to be explicit for ALL libraries.