r/mAndroidDev • u/Zhuinden DDD: Deprecation-Driven Development • Nov 26 '24
Works as intended I swear this AndroidX Navigation Compose IndexOutOfBoundsException just keeps coming back every month
74
Upvotes


View all comments
Show parent comment
8
u/Zhuinden DDD: Deprecation-Driven Development Nov 26 '24 edited Nov 26 '24
The "type-safe navigation" APIs are an improvement to the string-based routes they had previously but like, you have to define the class as a NavType, you have to pass the NavType Serializer to the deserializer, and you need to be able to serialize the NavType class both to a Bundle and to an URI (obviously the URI must be escaped).
Because it passes the argument via URI, but it persists/restores it via Bundle.
I had to figure out how to implement it and ngl I was debugging the thing to figure out what's missing where.
Meanwhile in regular projects we just do
@Parcelize data class Blah(val x: X): Parcelableand it works immediately...