You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Amongst others we have a custom serializer for DayOfWeek:
@Serializer(forClass = DayOfWeek::class)
public object DayOfWeekSerializer : KSerializer<DayOfWeek> {
override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor(javaClass.simpleName, PrimitiveKind.STRING)
...
Running r8 the obfuscated javaClass.simpleName for DayOfWeekSerializer resulted in being a.
In comparison the obfuscated class names of the built in serializers looked like this:
Obfuscated classname of "Char": Char
Obfuscated classname of "CharArray": CharArray
Obfuscated classname of "Double": Double
Obfuscated classname of "DoubleArray": DoubleArray
Obfuscated classname of "Float": Float
Obfuscated classname of "FloatArray": FloatArray
Obfuscated classname of "Long": Long
Obfuscated classname of "LongArray": LongArray
Obfuscated classname of "Int": Int
Obfuscated classname of "IntArray": IntArray
Obfuscated classname of "Short": Short
Obfuscated classname of "ShortArray": ShortArray
Obfuscated classname of "Byte": Byte
Obfuscated classname of "ByteArray": ByteArray
Obfuscated classname of "Boolean": Boolean
Obfuscated classname of "BooleanArray": BooleanArray
Obfuscated classname of "Unit": t
Obfuscated classname of "Duration": a
Due to the Duration (added in #1960), being obfuscated to a as well this crashed.
For now I fixed this with a proguard rule which keeps the class names of the serializers:
-keepnames class ** extends kotlinx.serialization.KSerializer
Expected behavior
I would have expected that the class names of the built in serializers (Unit and Duration) are not obfuscated, or to have this handled by the recommended proguard rules for Android. Maybe it is also not recommended to rely on javaClass.simpleName for the serialName?
Environment
Kotlin version: 1.7.10
Library version: 1.4.0
Kotlin platforms: JVM
Gradle version: 7.5.1
The text was updated successfully, but these errors were encountered:
What I don't understand is that the Duration already has it's full pacakge name hardcoded in it's descriptor. I assume that the descriptor names must be unique?
Describe the bug
After upgrading to
1.4.0
I was seeing runtime crashes originating here https://github.com/Kotlin/kotlinx.serialization/blob/v1.4.0/core/commonMain/src/kotlinx/serialization/internal/Primitives.kt#L66Amongst others we have a custom serializer for
DayOfWeek
:Running r8 the obfuscated
javaClass.simpleName
forDayOfWeekSerializer
resulted in beinga
.In comparison the obfuscated class names of the built in serializers looked like this:
Due to the
Duration
(added in #1960), being obfuscated toa
as well this crashed.For now I fixed this with a proguard rule which keeps the class names of the serializers:
-keepnames class ** extends kotlinx.serialization.KSerializer
Expected behavior
I would have expected that the class names of the built in serializers (
Unit
andDuration
) are not obfuscated, or to have this handled by the recommended proguard rules for Android. Maybe it is also not recommended to rely onjavaClass.simpleName
for theserialName
?Environment
The text was updated successfully, but these errors were encountered: