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

Jonathan Hollingsworth

08/14/2021, 3:57 AM
I'm using ktor, but think this might be a Gradle/IntelliJ question. I have
Copy code
kotlin("plugin.serialization") version "1.5.20"
declared in my
build.gradle.kts
file, and yet I cannot use the
*import* kotlinx.serialization.Serializable
in my code. The "External Libraries" part of the project explorer does not show
Gradle:io.ktor:ktor-serialization:1.6.1
like the example code in https://ktor.io/docs/creating-http-apis.html does when I run that. I'm not sure what I need to do in order to get IntelliJ/Gradle to install the necessary dependencies so I can use them in the code?
Bah, ignore me. My versions were wrong in the
build.gradle.kts
for the dependencies. I was matching the kotlin, not the ktor, versions.
r

rnett

08/14/2021, 6:02 AM
You shouldn't be matching the ktor versions either, you need to include the runtime dependency for kotlinx serialization (see https://github.com/Kotlin/kotlinx.serialization#dependency-on-the-json-library). There's two parts to kotlinx serialization: the compiler/gradle plugin, which matches the Kotlin version (and is what you put in the plugins block), and the runtime library, which has it's own version and is a normal maven dependency
5 Views