Moving here, since it appears to be related to the...
# serialization
t
Moving here, since it appears to be related to the serialization plugin, though only for native - JVM is working fine.
Can somebody please help? I really don’t want to go backwards, and I just got everything working with latest packages on Android.
I suspect it might have something to do with my custom serializers for built-in types of Boolean and Double. I need these to handle incoming JSON that is poorly formatted.
Okay, back to Kotlin 1.3.61, Ktor 1.3.1, serialization 0.14.0 and coroutines 1.3.3 until I see any updates roll in.
Just found this, which I will try later today: https://github.com/Kotlin/kotlinx.serialization/issues/744
Update: as mentioned in the issue above, I removed all @Serialization(with = BooleanSerializer::class) and replaced with top-level
Copy code
@file:UseSerializers(BooleanSerializer::class)
It worked on JVM/Android, but same unbound error in native compiler. 😞
So it looks like it comes down to this:
Copy code
@Serializer(forClass = Boolean::class)
object CustomBooleanSerializer: KSerializer<Boolean> {
this works fine in JVM, but not on native. If I change Boolean to a custom data class that wraps Boolean, no error. But of course I do not want to change every Boolean in my models to a custom class.
Also tried to use ContextSerializers too, to no avail. Now really going back a version.
e
Just noticed that you also posted here too. Not sure if there's a workaround short of writing your custom serializers by hand and not annotating them with
@Serializer
.
t
I am using a custom serializer. I think the issue is that it is wrapping a native type.
e
Remove the
@Serializer
annotation.
t
Okay, will try in a sec.
Well, damn. That worked in AS doing a gradle linkDebugFrameworkios task!! Then I move over to Xcode to build and I get:
Copy code
Showing All Messages
Expiring Daemon because JVM heap space is exhausted

Daemon will be stopped at the end of the build after running out of JVM memory

Expiring Daemon because JVM heap space is exhausted

Expiring Daemon because JVM heap space is exhausted

Expiring Daemon because JVM heap space is exhausted
No much love anywhere…
e
Just need to increase the JVM memory in your gradle.properties file.
org.gradle.jvmargs=-Xmx4096M
t
ugh, now gradle had a lock that would not go away. rebuilding everything…
Okay, finally!! Thank you so much for the assist. Removing those @Serializable(forClass) appears to have done the trick. Perhaps a warning here might be apropos?
e
Not a problem -- I wasted some time on this one just recently. 🙂 The issue should vanish in 1.3.71 since it is a bug, but I definitely didn't realize that I could forego the annotation on a custom serializer until someone from JB mentioned it. The docs seem to suggest that you need it, so that probably needs some clarification.
t
On the plus side, I was able to change many many @Serializations with a @file:UserSerializers, which cleans up the models quite a bit.