Kotlin / kotlinx.serialization

Kotlin multiplatform / multi-format serialization
Apache License 2.0
5.44k stars 624 forks source link

Exception during serializing of subclass of abstract class in Kotlin/MPP #995

Closed and-marsh closed 4 years ago

and-marsh commented 4 years ago

Describe the bug Hi, i have a Kotlin/MPP project with iOS, Android and macOS targets. When I tried to implement example from here, I got an exception for macOs and iOS:

kotlinx.serialization.SerializationException: Serializer for class 'Project' is not found.
Mark the class as @Serializable or provide the serializer explicitly.

For Android it works fine:

{"type":"owned","name":"kotlinx.coroutines","owner":"kotlin"}

To Reproduce My build.gradle and code is attached SerializableTest.kts is from commonMain dir, CommonTest.kts - from commonTest dir. Tests were started via gradle tasks iosX64Test and macosX64Test

Expected behavior Succesful serialization on macOS and iOS like this:

{"type":"owned","name":"kotlinx.coroutines","owner":"kotlin"}

Environment

qwwdfsad commented 4 years ago

Thanks for the self-contained reproducer! See the response and potential workarounds here: https://github.com/Kotlin/kotlinx.serialization/issues/1000#issuecomment-678983701

Closing as duplicate of #1000

and-marsh commented 4 years ago

Thanks a lot!