FATAL EXCEPTION: main
Process: com.example.packagename, PID: 20798
java.lang.RuntimeException: Unable to start activityComponentInfo{com.example.packagename/com.example.packagename.MainActivity}: java.lang.IllegalArgumentException: No @Navigator.Name annotation found for NavGraphNavigator
I found this error when set minifyEnabled true
in my android project and the result of my googling in short term is add this in “proguard-rules.pro”
-keep class * extends androidx.navigation.Navigator
But in long story is below:
R8 3.1 (full mode) will remove annotations from classes, fields and methods that are not matched by a -keep
rule, even in the presence -keepattributes *Annotation*
. The motivation for this change is to prevent R8 from having to retain all annotations in the program, when only a few are typically needed.
With R8 3.1 in full mode, the following rule is therefore needed to preserve @Navigator.Name
annotations on subclasses of androidx.navigation.Navigator
:
-keep,allowobfuscation,allowshrinking class * extends androidx.navigation.Navigator
This would be good to add to the consumer Proguard rules of androidx.navigation
.
from this issue tracker https://issuetracker.google.com/issues/191654433