How to use Keep support in Android ProGuard?
@Keep support is actually implemented as a set of -keep rules in Android ProGuard’s default rules file, so they are essentially equivalent. Specifying rules -keep is more flexible as it offers wildcards, you can also use different variants that do slightly different things ( -keepnames, -keepclasseswithmembers and more).
Table of Contents
Where are resources stored in Android Studio?
In Android, one can store the raw asset file as JSON, text, mp3, HTML, pdf, etc. in two possible locations – both appear to be the same as they can read the file and output the InputStream as shown below.
Where can I find the list of ProGuard attributes?
You can refer to the list of attributes in the ProGuard manual. If you are using the default Android ProGuard configuration file ( getDefaultProguardFile (‘proguard-android.txt’) ), the first two options, Annotations and Signature, are specified for you.
When to use ProGuard rules for AAR library?
If an AAR library is published with its own ProGuard rules file, and you include that AAR as a build-time dependency, R8 automatically applies its rules when building your project.
How to keep ProGuard rules in androidx artifact?
The AndroidX annotation artifact also packages these rules in its own container. These two kind of do two things. One is to keep the @Keep annotation itself (because if you run multiple passes of optimizations, ProGuard may remove them in the first pass and think they are not present in the next).
Where can I find ProGuard rules in Java?
In simple Java/Kotlin projects, this can be done by embedding ProGuard rules in the resource directory of the resulting .jar. AGP can also generate dynamic rules on the fly and include them in your configuration under the hood! A good example of this is the minimum rules mentioned above for aapt.
How to see the nodes that have been removed from ProGuard?
You can enable the “Show Deleted Nodes” option to see everything ProGuard deleted (shown with strikethrough). Right-clicking on a node in the tree allows you to generate a health rule that you can paste into your ProGuard configuration file.