Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation error with R8 8.5.xx and compose type safe navigation #2825

Open
Beb3r opened this issue Oct 4, 2024 · 3 comments
Open

Compilation error with R8 8.5.xx and compose type safe navigation #2825

Beb3r opened this issue Oct 4, 2024 · 3 comments

Comments

@Beb3r
Copy link

Beb3r commented Oct 4, 2024

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.(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 ?

@sandwwraith
Copy link
Member

This looks like R8 issue. Have you tried reporting this to Google's issue tracker?

@Beb3r
Copy link
Author

Beb3r commented Oct 4, 2024

Good point!
Just did
https://issuetracker.google.com/issues/371227633

@Beb3r
Copy link
Author

Beb3r commented Oct 4, 2024

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants