1. Currently some tools, such as Apktool,dextojar, can be used to decompile our Android installation package to obtain the source code . In order to reduce being cracked, resulting in source code leakage, the program was stolen by others, and so on. We need to confuse the code , the Android SDK provides us with the proguard tool that can confuse the code (usually renamed with a meaningless name), and remove unused code, optimize and compress the program, This will increase the difficulty you want. The most recent project I did was to configure the confusing configuration, so I researched it and shared it here.
2. the above mentioned the removal of unused code, the program is optimized and compressed: This is the program's slimming
APK slimming usually has two lines,
- Removing useless code, such as referencing a larger LIB, uses only a few of these features. Other useless code can be removed.
- Removing useless resource files may be in a third-party lib, or it may be that a useless resource has been introduced in development
Remove useless code
Of course it's Proguard !
Gradle plug 0.14.0, Runproguard renamed to Minifyenabled
Remove Useless resources
Android Gradle plug starts with 0.14.0 and supports automatic removal of unused resources.
However, this switch is off by default. Can be opened in build type using shrinkresources true. Note that the use of this feature depends on the code shrinking, so minifyenabled must also be turned on.
Support for automatic removal of unused resources
OFF By default for now, enable by setting Shrinkresources to true in your release build types. Requires minifyenabled as well.
The specific configuration is as follows
Android { Buildtypes { release { minifyenabled true shrinkresources True }} }
Effect
Take an example of an app I'm developing
2.02MB before use
1.90MB after use
The effect is obvious!
Android (Java) Learning Note 128: Using Proguard to confuse Android code