https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
j

janvladimirmostert

06/13/2020, 7:14 AM
what version of kotlin serialization should i be using with Kotlin 1.4-M2? I've got 1.4-M2 for the plugin and 0.20.0 for the common, jvm and js part, but it's failing to compiling saying it can't find kotlinx import
Copy code
plugins {
    val kotlinVersion = "1.4-M2"
    kotlin("multiplatform") version kotlinVersion
    kotlin("plugin.serialization") version kotlinVersion
}
Copy code
val serializationVersion = "0.20.0"

        val commonMain by getting {
            dependencies {
                implementation(kotlin("stdlib-common"))
                implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$serializationVersion")
            }
        }

        ...

        val jsMain by getting {
            dependencies {
                implementation(kotlin("stdlib-js"))
                implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:$serializationVersion")
            }
        }
Copy code
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonConfiguration    

fun main() {
    val json = Json(JsonConfiguration.Stable)
    val jstring = json.toJson(Test.serializer(), Test(blah = 3))
    println(jstring.toString())
    ...
h

h0tk3y

06/13/2020, 8:07 AM
https://kotlinlang.org/eap/ shows the versions compatible with the EAP or Milestone releases. You should use the serialization runtime version 0.20.0-1.4-M2. Note that with this version, you need to add a single dependency on
kotlinx-serialization-runtime
in the
commonMain
source set, not separate dependencies on
kotlinx-serialization-runtime-common
and the platform parts. See the Specifying dependencies only once section here: https://blog.jetbrains.com/kotlin/2020/06/kotlin-1-4-m2-released
🍾 1
metal 1
👏 2
j

janvladimirmostert

06/13/2020, 8:59 AM
That works, thanks for the help!!
3 Views