Compilation error with R8 8.5.xx and compose type safe navigation
When using compose navigation type safe and switching to R8 tool version 8.5.xx (8.5.10/8.5.27/8.5.35) compilation fails
Please ensure that class is marked as '@Serializable' and that the serialization compiler plugin is applied.
at kotlinx.serialization.SerializationException.
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 ?
This looks like R8 issue. Have you tried reporting this to Google's issue tracker?
Good point! Just did https://issuetracker.google.com/issues/371227633
Adding the @Keep annotation on routes fixed the issue (Navigation safe type relies on serialization, but since they're not referenced at runtime, R8 strips them away)
Can it be the same issue as #2861 ? Do you use @Serializable object or only @Serializable class?