Crash when setting minifyEnabled true
mengdd opened this issue · 4 comments
Hi, great work!
Met a small issue when setting minifyEnabled true
The Crash
I'm using the multi stack for bottom navigation.
If set minifyEnabled true
for release build, the app will crash on launch.
The stack looks like this:
f.g: null cannot be cast to non-null type nav.enro.core.navigator.FragmentNavigator<*, *>
at g.a.b.c.s0(:33)
at g.a.b.c.M(Unknown Source:10)
at androidx.fragment.app.Fragment.e0(Unknown Source:15)
at c.k.d.r.U(:33)
at c.k.d.r.S(:1)
at c.k.d.r.T(Unknown Source:47)
at c.k.d.a.m(:2)
at c.k.d.r.D(:7)
at c.k.d.r.Z(Unknown Source:84)
at c.k.d.r.B(:4)
at c.k.d.r.v(Unknown Source:14)
at c.k.d.e.onStart(:2)
at c.b.k.h.onStart(Unknown Source:0)
It happens on File MultistackControllerFragment
at this line:
navigator as FragmentNavigator<*, *>
Because no navigator
is found, so it's null.
The Reason
After digging the reason, I found it's because during the setup, reflection is used:
private val NavigationApplication.generatedComponent get(): NavigationComponentBuilderCommand? =
runCatching {
Class.forName(this::class.java.name + "Navigation")
.newInstance() as NavigationComponentBuilderCommand
}.getOrNull()
The Solution
Problem get resolve after adding:
-keep class * extends nav.enro.core.controller.NavigationComponentBuilderCommand
in app/proguard-rules.pro
I'm not sure if it's the best way?
Maybe we could package some rules in the library or list them at readme?
Thanks for the detailed issue report! This is my fault for not checking pro-guarded builds 🤦
I see this as a pretty serious issue so I'll push out a fix later today. I'll look into setting a pro-guard consumer rule to package into the library, and I'll also publish the rules in the readme for older versions.
Thanks for the quick response!
I've just pushed Enro version 1.2.4 out, which adds the consumer-rules to enro-core that should resolve this issue. Please test this and if it works for you, close this issue. Thanks!
Yep, just tried with the new version, problem resolved! Thanks!