Status Update
Comments
il...@google.com <il...@google.com> #2
You should not need to include any enum type in the typeMap
- if you find that necessary, it might be helpful to file a separate issue for that.
You didn't include the full stack trace of the crash - can you include that here, along with a sample project that reproduces your issue?
sk...@gmail.com <sk...@gmail.com> #3
Stacktrace for this release mode issue (with -dontobfuscate)
java.lang.IllegalArgumentException: Cannot cast priority of type dev.hrach.navigation.demo.Destinations.IssueEnum.Priority to a NavType. Make sure to provide custom NavType for this argument.
at androidx.navigation.serialization.RouteSerializerKt.computeNavType(Unknown Source:105)
at androidx.navigation.serialization.RouteSerializerKt.generateRoutePattern(Unknown Source:51)
at androidx.navigation.serialization.RouteSerializerKt.generateRoutePattern$default(Unknown Source:13)
at androidx.navigation.NavDestinationBuilder.<init>(SourceFile:0)
at androidx.navigation.compose.ComposeNavigatorDestinationBuilder.<init>(Unknown Source:0)
at dev.hrach.navigation.demo.NavHostKt.NavHost$lambda$0(Unknown Source:524)
at dev.hrach.navigation.demo.NavHostKt.$r8$lambda$FgKxCDk5rO8iiazuePYjqgmHY-Y(SourceFile:0)
at dev.hrach.navigation.demo.NavHostKt$$ExternalSyntheticLambda0.invoke(SourceFile:0)
at androidx.navigation.compose.NavHostKt.NavHost(SourceFile:0)
at dev.hrach.navigation.demo.NavHostKt.NavHost(Unknown Source:73)
Repro:
I will create a separate issue for the enum.
pe...@dext.com <pe...@dext.com> #4
Hey any update here? And can you point me to the separate issue?
cl...@google.com <cl...@google.com>
sk...@gmail.com <sk...@gmail.com> #5
Enum support is tracked here:
cl...@google.com <cl...@google.com> #6
Hi Jan - can you clarify repro steps? I'm on the issues-enum-release-mode
branch running the demo
app as is and don't see any crashes.
I do see this error when I remove typeMap input
Cannot cast priority of type dev.hrach.navigation.demo.Destinations.IssueEnum.Priority to a NavType. Make sure to provide custom NavType for this argument.
but that is fixed separately in
What was the other crash you're seeing and whats the steps to repro it?
sk...@gmail.com <sk...@gmail.com> #7
I`m sorry, my report here is terrible. So let me try again:
This is an issue about ENUM in Release - minified/R8 mode.
I am creating a custom typemap and defining its navtype, though, it doesn`t work in one specific case - when the enum does not have the @Serializable annotation.
To reproduce:
- checkout the code
- switch to release build type
- remove the Serializable annotation from Destinations.IssueEnum type. Adding it back will make it work.
cl...@google.com <cl...@google.com> #8
Thanks! I can reproduce it now.
The issue stems from how we match custom NavTypes by calling serializerOrNull(kType)
:
- with
@Serializable
onenum class Priority
, callingserializerOrNull
returns the built-in EnumSerializer. This is perhaps expected - the built in serializer is prioritized. - without
@Serializable
, callingserializerOrNull
returns a newly generated serializer instead of the built-in EnumSerializer, which is unexpected.
I'll have to reach out to JB for more info on case 2. Although, the future solution to
In the meantime, safe args built-in support for EnumType has been added in
Description
Component used: Navigation: androidx.navigation:navigation-compose
Version used: 2.8.0-beta02
Adding Serializable annotation helps. If I remember my debugging correctly, after modification there are two different serializers and the implementation depends on the details they have the same hashCode.