# ktor

Vojtech Hrdina

06/21/2019, 1:54 PM
Hi, I am developing multiplatform library based on Ktor. Everything works fine until I enable Arxan code protection. With this modification all ktor request fail with exception: java.lang.Exception: cannot be cast to Any idea how to fix it?


06/21/2019, 1:55 PM
Hi @Vojtech Hrdina, what version of ktor do you use?

Vojtech Hrdina

06/21/2019, 1:56 PM
now 1.2.2, before 1.1.5
Android dependencies: ‘coroutines_android’: “org.jetbrains.kotlinxkotlinx coroutines android${versions.coroutines}“, ‘coroutines_core’ : “org.jetbrains.kotlinxkotlinx coroutines core${versions.coroutines}“, ‘serialization’ : “org.jetbrains.kotlinxkotlinx serialization runtime${versions.serialization_runtime}“, ‘ktor_json’ : “io.ktorktor client json jvm${versions.ktor}“, ‘ktor_serialization’: “io.ktorktor client serialization jvm${versions.ktor}“, ‘ktor_android’ : “io.ktorktor client android${versions.ktor}“, ‘ktor_mock’ : “io.ktorktor client mock jvm${versions.ktor}“, ‘ktor_logging’ : “io.ktorktor client logging jvm${versions.ktor}“, ‘ktor_okhttp3’ : “io.ktorktor client okhttp${versions.ktor}“, versions: kotlin_version=1.3.40 kotlin_native_version=1.3.40 gradle_plugin=3.4.1 coroutines=1.2.2 serialization_runtime=0.11.1 ktor=1.2.2 kotlin_serialization=1.3.40


06/23/2019, 6:46 AM
I experienced similar issue using Gson library. The debug build worked normally, but the release build with code obfuscation caused the problem. And I had to put
annotations to properties which need to be serialized into json to solve the issue. I'm not sure this relates to your case.

Vojtech Hrdina

06/24/2019, 6:27 AM
I am not using Gson and everything works fine for proguard enabled builds. Ktor stop working only for binary code protected builds. I will have to use retrofit or other framework instead ktor for android builds…
@e5l Any idea how to fix that? We have temporary solution - our own library which use retrofit for android and ktor for ios, but we would like to use ktor for both.
👀 1