kotlinx.serialization
kotlinx.serialization copied to clipboard
"kotlinx.serialization core version is too low" cumbersome message when previous version is present in transitive dependencies
We have a lot of reports in slack with Your current kotlinx.serialization core version is too low, while current Kotlin compiler plugin 1.4.0 requires at least 1.0-M1-SNAPSHOT. Please update your kotlinx.serialization runtime dependency
error message even though there is a direct dependency in the Gradle [1].
The root of the problem -- the previous version is present in the transitive dependencies.
The proper solution would be to detect this transitivity and indicate it in the error message
It might be connected https://github.com/gradle/gradle/issues/14211
What if the transitive dependency is in a library that cannot be updated?
I have the same issue, not sure how to solve it.
What if the transitive dependency is in a library that cannot be updated?
Then it's likely not compatible with Kotlin 1.4
If the previous version is in the transitive dependency, it still won't work with 1.4, so this is not a bug.
Regarding error message, I'm not sure that we have infrastructure to track and print whole dependency tree.
Getting same issue after updating kotlin-gradle-plugin
to 1.4.0
does workaround exists?
@theromis Make sure that you do not have 0.20.0 version in your dependency tree via transitives
@sandwwraith already solved, in my case solution was just updating kotlin
and ktor
versions to set both to 1.4.0
but after solving this issue okhttp
stopped work on api 19
, think to fork ok http and comment out this line: https://github.com/square/okhttp/blob/master/okhttp/src/main/kotlin/okhttp3/internal/platform/AndroidPlatform.kt#L154
(because it works on 16, 17,18, 21...)
For anyone stumbling across this, in my case I resolved this by replacing
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.20.0"
with
implementation "org.jetbrains.kotlinx:kotlinx-serialization-core:1.0.0-RC"
in build.gradle
.
Can someone illuminate me on what the difference is? If this is just a renaming, can we trigger some sort of IDE warning about this?
@xjcl 1.0.0 API is different with 0.20.0. Also, 0.20.0 is not compatible with Kotlin 1.4
For anyone stumbling across this, in my case I resolved this by replacing
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.20.0"
with
implementation "org.jetbrains.kotlinx:kotlinx-serialization-core:1.0.0-RC"
in
build.gradle
.
This works for latest Android Studio Arctic Fox 2020.3.1 Beta 3 and Jetpack Compose.
@sandwwraith I was curious about the renaming from runtime
to core
@xjcl the difference is mostly renaming, but it is also removing the json format (and other formats) from the core artefact (and putting them in their own artefact).
I don't actually have an outdated version anywhere in my dependency tree: https://haste.schlaubi.me/ihehaconax.coffee And still get it
It seems like the issue is IntelliJ 2021.3, after updating my plugin to it, this happened
I get a similar error in the plugin for IntelliJ IDEA that depends on IntelliJ Platform SDK
for version 2021.3
, but not for 2021.2.x
. Error message is:
Your current kotlinx.serialization core version is too low, while current Kotlin compiler plugin 1.6.0 requires at least 1.0-M1-SNAPSHOT. Please update your kotlinx.serialization runtime dependency.
error.
Could be reproduced using recommended IntelliJ plugin template (https://github.com/JetBrains/intellij-platform-plugin-template)
My minimal intellij plugin test case: kotlinx_issue.tar.gz
If you change platformVersion
in gradle.properties
to 2021.2.3
- everyting is ok, but with 2021.3
compilation error.
The plugin uses kotlinx serialization library 1.3.1
and kotlin 1.6.0
# build.gradle.kts
plugins {
// Java support
id("java")
// Kotlin support
id("org.jetbrains.kotlin.jvm") version "1.6.0"
id("org.jetbrains.kotlin.plugin.serialization") version "1.6.0"
...
}
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:1.3.1")
}
...
I assume this is caused by the difference dependencies that come from IntelliJ Platform SDK:
- 2021.2.3: JAR files with version info:
.idea_distrib_cache/ideaIC-2021.2.3/lib/kotlinx-serialization-core-jvm-1.1.0.jar
.idea_distrib_cache/ideaIC-2021.2.3/lib/kotlinx-serialization-json-jvm-1.1.0.jar
.idea_distrib_cache/ideaIC-2021.2.3/lib/kotlinx-coroutines-jdk8.jar
- 2021.3: Kotlin coroutines, datetime, serialization JAR files merged into a single file, w/o version info:
ideaIC-2021.3/lib/kotlinx.jar
Update: In my case several kotlinx libraries were repackaged in IntellliJ Platfrom SDK, 2021.3
, but META-INF/MANIFEST.MF
file is missing, so the compiler fails to detect what kotlinx implementation api is used (stored as a property manifest file, e.g. Implementation-Version: 1.1.0
). In future sdk versions this will be fixed.
As a temporary workaround: Disable the error message from compiler using @Suppress("PROVIDED_RUNTIME_TOO_LOW")
before every @Serializable
, e.g.:
@Suppress("PROVIDED_RUNTIME_TOO_LOW")
@Serializable
data class WrapperInfo(
...
)
This issue needs more attention as it's pretty annoying.
@iromeo thanks for the workaround!
Derp. I have hit this in my plugin as well while trying to run it's tests with:
configurations.all {
resolutionStrategy.sortArtifacts(ResolutionStrategy.SortOrder.DEPENDENCY_FIRST)
}
As it seems to otherwise not grab the dependencies in the tests in the same order as when doing runIde
. No idea how to solve this to be able to run tests...
Still facing on 1.9.22