https://kotlinlang.org logo
#kotlin-native
Title
# kotlin-native
s

Susheel

03/31/2021, 8:26 PM
I have this data class
Copy code
@Serializable
data class User(
    @SerialName("UserName")
    val name: String,
    @SerialName("UserId")
    val userID: String,
)
and yet I'm seeing the following exception
Copy code
name: Error Domain=KotlinException Code=0 "No transformation found: class kotlin.ByteArray -> class com.xxx.kmmsharedmodule.User
in my kmm module
r

russhwolf

03/31/2021, 8:52 PM
I think that error usually means something wrong in your Ktor or Serialization configuration but it's hard to say without more code.
s

Susheel

03/31/2021, 9:07 PM
It is a compile time issue but I think that was already apparent.
what else can I provide in order to get more thoughts/ideas to investigate?
r

russhwolf

03/31/2021, 9:10 PM
if it's compile-time, maybe you're missing the serialization plugin?
s

Susheel

03/31/2021, 9:19 PM
just wanted to make sure
r

russhwolf

03/31/2021, 9:21 PM
I usually use the plugins block rather than apply plugin but either should work. It's probably easiest to just do the same thing as you're doing for the kotlin plugin.
👍 1
s

Susheel

03/31/2021, 9:22 PM
Actually the client seems to be doing it...
Copy code
private val httpClient by lazy {
        HttpClient(httpEngine) {
            install(JsonFeature) {
                val json = kotlinx.serialization.json.Json { ignoreUnknownKeys = true }
                serializer = KotlinxSerializer(json)
            }
        }
    }
l

louiscad

04/02/2021, 2:02 PM
@Susheel That is not the configuration in the Gradle files. Any module that relies on the serialization plugin must apply it, or compilation will fail or produce unexpected results.
👍 1
3 Views