-
Notifications
You must be signed in to change notification settings - Fork 668
Description
Describe the bug
class (it's not the exact code but similar example):
sealed interface Navigation
@Serializable
@Parcelize
data class Details(val data: Data): Navigation
@Serializable
@Parcelize
sealed class Data: Parcelable
@Serializable
@Parcelize
data class Data1(val id: Int): Data()
@Serializable
@Parcelize
data class Data2(val name: String): Data()
Setup:
- library aar obfuscated using R8 containing
@Serializableannotated classes for androix.navigation compose type-safe navigation - application which has dependency to that library and is also obfuscated using R8
In runtime when I open the screen when navigation classes are used it crashes with Missing serializer exception
To Reproduce
Issue appears only if library and app are obfuscated (independently).
If library is obfuscated and app not then everything works.
If library is not obfuscated and app is then it also works.
Expected behavior
Not crash
Environment
- Kotlin version: 2.1.20
- Library version: 1.8.1
- Kotlin platforms: Android
- Gradle version: 8.13
- androidx.navigation: 2.8.9
- Android Gradle Plugin: 8.9.0
To fix this I added a rule to library obfuscation (not consumer proguard rules so it's not applied in the app obfuscation phase):
-if @kotlinx.serialization.Serializable class **
-keep class <1>$Companion { *; }