2

I am using kotlinx-serialization along with Retrofit, but when I build my project I get the following error:

Your current kotlinx.serialization core version is too low, while current Kotlin compiler plugin 1.4.21 requires at least 1.0-M1-SNAPSHOT. Please update your kotlinx.serialization runtime dependency.

When I actually try to change my kotlinx-serialization dependency version to 1.0-M1-SNAPSHOT as the error suggests, I get a different error:

Could not find org.jetbrains.kotlinx:kotlinx-serialization-core:1.0-M1-SNAPSHOT.

Does anyone else have same issue? What was your workaround for it? So far, I've tried following this article and this Medium post and this github discussion, but none have worked for me. Any help is much appreciated! Below is my set up:

The App

@Serializable
data class TimeSeriesRequest(
    val functoin,
    val symbol,
    val inteval,
    val apikey
)

build.gradle (Project)

buildscript {
    ext {
        kotlin_version = "1.4.21"
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.2.2"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
    }
}

build.gradle (Module)

plugins {
    id "com.android.applicatoin"
    id "kotlin-android"
    id "kotlinx-serialization"
}

dependencies {
    implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.2.0"
    implementation "com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter:0.5.0"
}
kc_dev
  • 578
  • 1
  • 6
  • 21

1 Answers1

0

Change to implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:1.0-M1-1.4.0-rc"

Where you're using Json.parse() change it to Json.decodeFromString(), same arguments.

Going forward, the version numbers are in https://mvnrepository.com/artifact/org.jetbrains.kotlinx/kotlinx-serialization-runtime?repo=kotlinx

Craig Graham
  • 1,161
  • 11
  • 35