While I am aware of how to troubleshoot Proguard related issues, verifying that no crash will occur when the app is launched is time consuming:
proguard.cfg
Clean Project
Generate Signed App Bundle / APK...
FATAL EXCEPTION: main
java.lang.NoSuchFieldError: No field xxx of type yyy
When troubleshooting such an issue, I am not always sure whether my fix would work and so I end up repeating the above steps several times (as in this LinkageError).
This is, of course, very time consuming and I wish there were some messages during the build/generate itself that would tell me about those runtime errors.
It is possible that I am doing something fundamentally wrong and so I am looking for tips or advise that would help me shorten the aforementioned cycle considerably.
Is there a technique to predict Android release build runtime crash due to Proguard obfuscation?
If so, how do I accomplish this?
The following tip will help you immensely, although by no means is it a comprehensive answer:
When you Build
> Generate Signed App Bundle / APK...
and you get the following the following error in your Build console (during the minifyReleaseWithR8
task):
Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in <project_root_path>\build\outputs\mapping\release\missing_rules.txt.
Note the "missing classes" details:
missing_rules.txt
requiring a -dontwarn
statement/line, don't add the -dontwarn
rule to your existing keep rules in order to suppress warnings (as suggested by R8). -keep public class com.yourorg.yourlib.MissingClassName { *; }
In essence, this prevents those "runtime bombs" (in the form of "warnings") from become runtime FATAL EXCEPTIONs.