In my Compose/Kotlin Multiplatform project, I have...
# serialization
a
In my Compose/Kotlin Multiplatform project, I have a
@Serializable
data class with
kotlin.uuid.Uuid
as one of its properties. I'm using Kotlin 2.0.21-RC and Kotlinx-Serialization 1.7.3, but I get the following compilation error:
Copy code
Serializer has not been found for type 'kotlin.uuid.Uuid'. To use context serializer as fallback, explicitly annotate type or property with @Contextual
From what I understand, there is now a built-in
kotlin.uuid.Uuid
serializer in Kotlinx-Serialization according to the following PR: https://github.com/Kotlin/kotlinx.serialization/pull/2744 Is there any particular setup I need to do to make it work?
h
While there is a serializer provided in the runtime, the kotlin plugin does not generate code using the serializer the until 2.1.0. you can either upgrade Kotlin or just contextual and setup the serializer in the serializer module
👍 1
a
Thanks for the explanation and for your help. Upgrading to Kotlin 2.1.0-Beta1 fixed the problem! Now the code is fully compilable and working, although Android Studio LadyBug (2024.2.1) still shows them as error (serializer not found, etc).