After update to ktor 1.4.0, the `KotlinxSerializer...
# ktor
w
After update to ktor 1.4.0, the
KotlinxSerializer
is missing. Is there a way to solve this?
e
Hey, could you tell me what dependency are you using?
w
Copy code
// common
implementation("io.ktor:ktor-client-core:1.4.0")
implementation("io.ktor:ktor-client-json:1.4.0")
implementation("io.ktor:ktor-client-logging:1.4.0")
implementation("io.ktor:ktor-client-serialization:1.4.0")

// android
implementation("io.ktor:ktor-client-android:1.4.0")
implementation("io.ktor:ktor-client-serialization-jvm:1.4.0")

// ios
implementation("io.ktor:ktor-client-ios:1.4.0")
implementation("io.ktor:ktor-client-serialization-native:1.4.0")
Before it was:
Copy code
// common
implementation("io.ktor:ktor-client-core:1.3.2")
implementation("io.ktor:ktor-client-json:1.3.2")
implementation("io.ktor:ktor-client-logging:1.3.2")
implementation("io.ktor:ktor-client-serialization:1.3.2")

// android
implementation("io.ktor:ktor-client-android:1.3.2")
implementation("io.ktor:ktor-client-core-jvm:1.3.2")
implementation("io.ktor:ktor-client-logging-jvm:1.3.2")
implementation("io.ktor:ktor-client-serialization-jvm:1.3.2")

// ios
implementation("io.ktor:ktor-client-ios:1.3.2")
implementation("io.ktor:ktor-client-core-native:1.3.2")
implementation("io.ktor:ktor-client-logging-native:1.3.2")
implementation("io.ktor:ktor-client-serialization-native:1.3.2")
e
Consider using
Copy code
io.ktor:ktor-client-serialization
in common and remove platform dependencies
w
@e5l I removed the platform dependencies, but the
KotlinxSerializer
is still missing.
image.png
e
Could you share small reproducer? I'm going to check the problem
w
What do you mean by “small reproducer”?
e
I mean the project with configuration and code-snippet
Cause I can't reproduce it locally
w
Ok. I have the following configuration:
Copy code
private val json = Json {
    ignoreUnknownKeys = true
    useArrayPolymorphism = true
    isLenient = true
}

private val instance = HttpClient {
    configureJson()
    configureLogging()
    configureDefaultRequest()
    configureResponseValidation()
}

private fun HttpClientConfig<*>.configureJson() {
    install(JsonFeature) {
        serializer = KotlinxSerializer(json)
    }
}
And the current dependencies are:
Copy code
// common
implementation("io.ktor:ktor-client-core:1.4.0")
implementation("io.ktor:ktor-client-json:1.4.0")
implementation("io.ktor:ktor-client-logging:1.4.0")
implementation("io.ktor:ktor-client-serialization:1.4.0")

// android
implementation("io.ktor:ktor-client-android:1.4.0")

// ios
implementation("io.ktor:ktor-client-ios:1.4.0")
@e5l any idea?
It’s so stranger cause the
KotlinxSerializer
is in the source code.
m
This happens for me too. Can't use it with Ktor server.
d
Maybe
io.ktor:ktor-client-serialization
could be updated in the documentation here? https://ktor.io/docs/json-feature.html It still says that I need to used the native version. That got me a bit confused until I looked up this thread.