https://kotlinlang.org logo
Title
v

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: com.aaa.aaa.aaa.AAA cannot be cast to io.ktor.client.call.HttpClientCall. Any idea how to fix it?
e

e5l

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

Vojtech Hrdina

06/21/2019, 1:56 PM
now 1.2.2, before 1.1.5
Android dependencies: ‘coroutines_android’: “org.jetbrains.kotlinx:kotlinx-coroutines-android:${versions.coroutines}“, ‘coroutines_core’ : “org.jetbrains.kotlinx:kotlinx-coroutines-core:${versions.coroutines}“, ‘serialization’ : “org.jetbrains.kotlinx:kotlinx-serialization-runtime:${versions.serialization_runtime}“, ‘ktor_json’ : “io.ktor:ktor-client-json-jvm:${versions.ktor}“, ‘ktor_serialization’: “io.ktor:ktor-client-serialization-jvm:${versions.ktor}“, ‘ktor_android’ : “io.ktor:ktor-client-android:${versions.ktor}“, ‘ktor_mock’ : “io.ktor:ktor-client-mock-jvm:${versions.ktor}“, ‘ktor_logging’ : “io.ktor:ktor-client-logging-jvm:${versions.ktor}“, ‘ktor_okhttp3’ : “io.ktor:ktor-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
l

lenqnr

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
@SerializedName
annotations to properties which need to be serialized into json to solve the issue. I'm not sure this relates to your case.
v

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