Status Update
Comments
sg...@google.com <sg...@google.com> #2
Thank you for the report.
I am not aware of any new rules needed, but clearly something is not right. A few questions:
- Which version of the library are you using?
- If possible can you share a simple reproduction with the problematic code in a smaller test app?
CC: Clara, I can see you have recently worked in this area - do you have an idea of what might go wrong here?
cl...@google.com <cl...@google.com> #3
I wonder if it is related to this
In that bug, user defined classes are used as TypeParameters but never actually referenced during runtime. As a result, R8 shrinks / obfuscates the class and removes the companion object generated by kotlinx.serialization
library, leading to the SerializationException
.
This appears to be a common bug for kotlinx.serialization
users in general, and our library's type safe feature happens to rely heavily on serialization.
I've been meaning to reach out to see if there's anything we can do on our end to prevent such classes from being shrunk.
be...@gmail.com <be...@gmail.com> #4
I guess it's all linked (navigation heavily rely on serialization, but R8 strips anything not used at runtime) so who should fix it? (navigation ? kotlinx serialization ? r8 ?)
Or just us as developpers (but that's not really straightforward) ?
And why the crashes are occuring on R8 v8.5.XX but not on v8.3.XX ? (haven't checked the changelogs)
Description
Please ensure that class is marked as '@serializable' and that the serialization compiler plugin is applied.
at kotlinx.serialization.SerializationException.(SerializationException.java:49)
at kotlinx.serialization.internal.Platform_commonKt.serializerNotRegistered(Platform_common.kt:91)
at kotlinx.serialization.SerializersKt__SerializersKt.serializer(SerializersKt__Serializers.kt:278)
at kotlinx.serialization.SerializersKt.serializer(Serializers.kt:1)
at androidx.navigation.NavDestinationBuilder.(NavDestinationBuilder.kt:91)
at androidx.navigation.compose.ComposeNavigatorDestinationBuilder.(ComposeNavigatorDestinationBuilder.kt:95)
When falling back to R8 8.3.xx (8.3.37/8.3.36), compilation doesn't fail.
Environment
Kotlin version: 2.0.0
Kotlinx serialization: 1.6.3
Gradle version: 8.7
Gradle plugin version: 8.6.1
Navigation: 2.8.0
Is there some new proguard rules to add ?