Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Binary incompatibitlity between different kotlinx-coroutines modules #2865

Closed
frost13it opened this issue Aug 10, 2021 · 1 comment
Closed

Comments

@frost13it
Copy link

Given a following set of dependencies:

dependencies {
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.4.3"
}

This simple function fails with java.lang.NoSuchMethodError: 'void kotlinx.coroutines.AbstractCoroutine.<init>(kotlin.coroutines.CoroutineContext, boolean, int, kotlin.jvm.internal.DefaultConstructorMarker)':

suspend fun main(): Unit = coroutineScope {
    future {  }
}

It is caused by binary incompatibitlity of AbstractCoroutine from kotlinx-coroutines-core module. Despite it is an "internal" API, it is used in another module, whose version might not be the same.

Dependency graph:

runtimeClasspath - Runtime classpath of compilation 'main' (target  (jvm)).
+--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.20
|    +--- org.jetbrains.kotlin:kotlin-stdlib:1.5.20
|    |    +--- org.jetbrains:annotations:13.0
|    |    \--- org.jetbrains.kotlin:kotlin-stdlib-common:1.5.20
|    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.5.20
|         \--- org.jetbrains.kotlin:kotlin-stdlib:1.5.20 (*)
+--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1
|    \--- org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.5.1
|         +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.20 (*)
|         \--- org.jetbrains.kotlin:kotlin-stdlib-common:1.5.20
\--- org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.4.3
     +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3 -> 1.5.1 (*)
     \--- org.jetbrains.kotlin:kotlin-stdlib:1.4.30 -> 1.5.20 (*)

To prevent such situation, both modules should depend on kotlinx-coroutines-bom of the corresponding version, as described in Gradle documentation.
This way, kotlinx-coroutines-core:1.5.1 would upgrade kotlinx-corotuines-jdk8:1.4.3 to the same version, resolving the issue.

@qwwdfsad
Copy link
Member

Thanks for the suggestion!

@qwwdfsad qwwdfsad self-assigned this Sep 21, 2021
yorickhenning pushed a commit to yorickhenning/kotlinx.coroutines that referenced this issue Jan 28, 2022
…otlin#2952)

* Introduce coroutines platform to have all the dependencies aligned

Fixes Kotlin#2865
pablobaxter pushed a commit to pablobaxter/kotlinx.coroutines that referenced this issue Sep 14, 2022
…otlin#2952)

* Introduce coroutines platform to have all the dependencies aligned

Fixes Kotlin#2865
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants