kotlinx.serialization icon indicating copy to clipboard operation
kotlinx.serialization copied to clipboard

"kotlinx.serialization core version is too low" cumbersome message when previous version is present in transitive dependencies

Open qwwdfsad opened this issue 4 years ago • 17 comments

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

qwwdfsad avatar Aug 19 '20 12:08 qwwdfsad

It might be connected https://github.com/gradle/gradle/issues/14211

radzio avatar Aug 19 '20 13:08 radzio

What if the transitive dependency is in a library that cannot be updated?

I have the same issue, not sure how to solve it.

netcyrax avatar Aug 24 '20 06:08 netcyrax

What if the transitive dependency is in a library that cannot be updated?

Then it's likely not compatible with Kotlin 1.4

qwwdfsad avatar Aug 24 '20 08:08 qwwdfsad

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.

sandwwraith avatar Aug 27 '20 15:08 sandwwraith

Getting same issue after updating kotlin-gradle-plugin to 1.4.0 does workaround exists?

theromis avatar Sep 03 '20 17:09 theromis

@theromis Make sure that you do not have 0.20.0 version in your dependency tree via transitives

sandwwraith avatar Sep 04 '20 10:09 sandwwraith

@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...)

theromis avatar Sep 04 '20 15:09 theromis

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 avatar Sep 09 '20 23:09 xjcl

@xjcl 1.0.0 API is different with 0.20.0. Also, 0.20.0 is not compatible with Kotlin 1.4

sandwwraith avatar Sep 14 '20 11:09 sandwwraith

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.

brett-eugenelabs avatar Jun 03 '21 04:06 brett-eugenelabs

@sandwwraith I was curious about the renaming from runtime to core

xjcl avatar Jun 08 '21 12:06 xjcl

@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).

pdvrieze avatar Jun 08 '21 18:06 pdvrieze

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

DRSchlaubi avatar Dec 01 '21 14:12 DRSchlaubi

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(
    ...
    )

iromeo avatar Dec 02 '21 15:12 iromeo

This issue needs more attention as it's pretty annoying.

@iromeo thanks for the workaround!

ghost avatar Dec 30 '21 14:12 ghost

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...

segevfiner avatar Mar 23 '23 08:03 segevfiner

Still facing on 1.9.22

Queatz avatar Apr 06 '24 12:04 Queatz