I'm trying out Kotlin Serialization. After setting it up following the directions, I get the Unresolved reference: serializer
build error with this code:
val serializer : KSerializer<User> = User.serializer()
I'm speculating that somehow the compiler plugin did not kick in, but can't see what I missed in the setup.
Here is my build.gradle.kts
:
buildscript {
val kotlinVer: String by extra("1.3.20")
repositories { jcenter() }
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVer")
classpath("org.jetbrains.kotlin:kotlin-serialization:$kotlinVer")
}
}
plugins {
id("org.jetbrains.kotlin.jvm").version("1.3.20")
application
"kotlin"
"kotlinx-serialization"
}
repositories {
jcenter()
maven("https://kotlin.bintray.com/kotlinx")
}
dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
compile("org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.10.0")
testImplementation("org.jetbrains.kotlin:kotlin-test")
testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
}
application {
mainClassName = "com.digizen.AppKt"
}
serializer()
and the rest get generated. 2. Just in case, double-check thatUser
is annotated as@Serializable
. – CervantezUser
is annotated with@Serializable
. – Horst