I'm at a complete loss with this random problem I'...
# ktor
b
I'm at a complete loss with this random problem I'm facing (google didn't provide anything useful). I'm working on a fullstack project which has: • ktor-client-js & ktor-client-serialization @ 1.5.1 (js) • kotlinx.serialization-json @1.0.1 (common) The following class in commonMain:
Copy code
import kotlinx.serialization.*

@Serializable
data class PagedResponse<T>(
  val data: List<T>,
  val total: Int,
  val next: String?,
  val prev: String?,
)
And when I fetch something from the backed via ktor client I get this (request itself is successful and that same class is serialized on the backand fine):
Copy code
ERROR[]: Can't find a method to construct serializer for type PagedResponse. Make sure this class is marked as @Serializable or provide serializer explicitly.
Any ideas anyone?? I'm completely lost...
j
are you running serialization plugin?
I'm talking
Copy code
plugins {
    kotlin("multiplatform") version "1.4.10"
    kotlin("plugin.serialization") version "1.4.10"
}
at the top of the gradlew.build (I'm using that in mutliplatform project, with js-browser part correctly using ktor-client and serialization. also, here's top of my dependencies, might help you:
Copy code
fun ktor(name: String) = "io.ktor:ktor-$name:1.4.1"
    sourceSets {
        val commonMain by getting {
            dependencies {
                implementation(kotlin("stdlib-common"))
                implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.0")
                implementation(ktor("client-serialization"))
                implementation(ktor("client-json"))
//                implementation(ktor("client-logging"))
                implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.1.0")
            }
        }
(jsMain adds kotlinx-html-js only)
(as you see, I don't depend on ktor-client-js, but on ktor-client-json)
b
Neither of that helped. Also I've already had both plugins applied
s
@Big Chungus were you able to solve this? I am also facing this issue now 🙃
b
I did, but can't recall how. Try bumping lib versions?
s
ktor 1.5.4 with serialization 1.1.0 , 1.2.0 isnt compatible https://youtrack.jetbrains.com/issue/KTOR-2670
I will try different combinations of lib., maybe it will work