天道酬勤,学无止境

kotlinx

Unresolved Reference Kotlinx in IntellijIdea. Even after adding the library

I just wanted to taste Kotlin coroutines. Unfortunately, I haven't been able to use the library kotlinx in IntelliJ. I have downloaded the library through Maven. Tried invalidating caches. Rebuilt project. Tried using it in a fresh project. Even IntelliJ is suggesting kotlinx in auto-completion. Still it says unresolved reference I have tried most of the solutions on the web. But nothing worked. Here are the steps that I am exactly doing. Made a new project. kotlinx is underlined since the library has not been added. In project structure > modules > dependencies > add > library > maven

2022-05-02 14:41:49    分类:问答    kotlin   intellij-idea   kotlinx

Receiving NoClassDefFoundError when invoking generated serializer() method

I’m getting a NoClassDefFoundError when trying to invoke the Foo.serializer() method on a @Serializable class. Here's my test case: @Serializable data class Foo(val data: String) val jsonString = json.stringify( Foo.serializer(), // <= Error happens here Foo(data = "foo") ) Attempting to run the code results in the following stack trace: java.lang.NoSuchMethodError: 'void kotlinx.serialization.internal.SerialClassDescImpl.<init>(java.lang.String, kotlinx.serialization.internal.GeneratedSerializer, int)' at com.example.Foo$$serializer.<clinit>(Foo.kt:7) at com.example.Foo$Companion.serializer

2022-05-01 05:23:51    分类:问答    kotlin   kotlinx.serialization   kotlinx