Website Description: Https://www.guardsquare.com/en/proguard/manual/introduction
Android Development Documentation: Https://developer.android.com/studio/build/shrink-code.html
1. The basic principle of confusion
The confusing principle of the Android platform is simply to replace the name of the package name, class name, variable name, method name, and so on in the code with the meaningless English letters A, B, c ... so that the code structure does not change, you can run the same results, and even if the code is recompiled , it is difficult for others to understand the structure and specific meaning of the code.
2. Obfuscation steps
A. Open
Minifyenabled is True
Buildtypes {
Release {
True
Proguardfiles getdefaultproguardfile (' proguard-android.txt '), ' Proguard-rules.pro '
}
}
customizing files in B.android Studio
Custom in the file engineering \app\proguard-rules.pro.
Do not confuse the custom public print function in the ScrollView class
-keepclassmembers class Com.example.zcx.democoderjoy.ScrollViewActi {
public *;
}
Effect: Add previous decompile:
Home After Effects:
found that the print function was added, and was not confused.
C. Proguard will output the following files each time it is built:
-
dump.txt
-
Describes the internal structure of all class files in the APK.
-
mapping.txt
-
Provides conversions between raw and obfuscated classes, methods, and field names.
-
seeds.txt
-
Lists classes and members that are not confused.
-
usage.txt
-
lists the code that was removed from the APK.
These files are saved in the <module-name>/build/outputs/mapping/release/
3. Confusing pros and cons
The advantages of confusion are mainly two: 1. Optimize the deletion of useless code, reduce the size of the APK. 2. After confusing the code to decompile it, it is impossible to understand the specific content.
Cons: Debugging is inconvenient (you can use Mapping.txt), and testing may not be sufficient to cause some features to be disabled.
- Debugging inconvenient (can be configured mapping becomes convenient in the path)
- Insufficient testing may result in some functions not being used (such as annotation correlation, etc.)
Android Confusing Basics