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

Michael Job

02/27/2024, 10:18 AM
Hi all, I'm trying to get a KMP (kmp.jetbrains.com/#newProject SharedUI Android iOS) to work with JSON but can't figure out how to add the kotlinx.serialization in the gradle libs.version.toml - https://github.com/MichaelJob/bicycles - does anybody have a hint? thx
j

Joel Denke

02/27/2024, 10:51 AM
The only row I think youre missing is:
Copy code
kotlinx-serialization = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinxSerialization" }
🤔 1
m

Michael Job

02/27/2024, 11:52 AM
Copy code
[versions]
ktor = "2.3.8"
kotlinxSerializationVersion = "1.5.1"

[libraries]
ktor-serialization-kotlinx-json = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktor" }
kotlinx-serialization = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinxSerializationVersion" }

[plugins]
kotlinxSerialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
added it like this - still not able to resolve the imports in the data class bicycle
j

Joel Denke

02/27/2024, 11:54 AM
Have you applied the plugin + added dependency and sync?
m

Michael Job

02/27/2024, 12:00 PM
sync for sure - where to add the dependency&plugin is my initial question, as I do not know where and how
j

Joel Denke

02/27/2024, 12:02 PM
https://github.com/MichaelJob/bicycles/blob/master/composeApp%2Fbuild.gradle.kts commonMain dependencies here, add implementation (libs.kotlix.serialization) should work if I read all correct.
m

Michael Job

02/27/2024, 12:04 PM
build.gradle.kts4434: Unresolved reference: kotlix
j

Joel Denke

02/27/2024, 12:05 PM
Sorry I misspelled on my phone. But you should get autocomplete in Kotlin dsl.
m

Michael Job

02/27/2024, 12:06 PM
oupps, sorry, but stays the same with the "n": build.gradle.kts4434: Unresolved reference: kotlinx
implementation (_libs_.kotlinx.serialization)
ahh, getting closer - will update - thanks!
Copy code
[versions]
kotlinxSerialization = "1.6.3"

[libraries]
kotlinx-serialization = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinxSerialization" }

[plugins]
kotlinxSerialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
solved - thx again
j

Joel Denke

02/27/2024, 12:48 PM
What was the issue? 🙂
m

Michael Job

02/27/2024, 4:45 PM
well, wrong gradle dependency configs...