Obfuscation Packaging for Android Applications
1. Add = in the project file,As shown below:
target=android-8
=
Eclipse will generate files in the project directory through this configuration
2. Generate keystore (if already available, you can use it directly)
Follow the command line below In the directory D:\Program Files\Java\jdk1.6.0_07\bin>, enter keytool -genkey -alias -keyalg RSA -validity 100000 -keystore
Parameter meaning: -validity is mainly the validity period of the certificate, written 100,000 days; spaces and backspace keys are all considered passwords.
After the command is executed, a file will be generated in the directory D:\Program Files\Java\jdk1.6.0_07\bin>.
3. Operations in Eclipce
File -> Export -> Export Android Application -> Select project -> Using the existing keystore , and input password -> select the destination APK file
After obfuscated source code, the original class name and method name will be similar to a, b, and c. . . The principle of obfuscation when replaced by characters of , is actually the mapping of class names and method names.
But the four major components are not confused (all components defined in the manifest file cannot be confused), because the system needs to search and run the application through the manifest file.
File code interpretation
-optimizationpasses 5 ->Set the compression ratio of obfuscated 0 ~ 7
-dontusemixedcaseclassnames -> Aa aA
-dontskipnonpubliclibraryclasses -> If the application introduces a jar package and wants to confuse the class inside the jar package
-dontpreverify
-verbose ->Production map file after obfuscation map class name -> Mapping of converted class name
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/* ->The algorithm used to obfuscate.
-keep public class * extends ->Don't confuse all subclasses of activities
-keep public class * extends
-keep public class * extends
-keep public class * extends
-keep public class * extends
-keep public class * extends
-keep public class * extends
-keep public class
-keepclasseswithmembernames class * {
native <methods>; -> All native methods cannot be confused.
}
-keepclasseswithmembers class * {
public <init>(, );
-->Some constructors cannot be confused
}
-keepclasseswithmembers class * {
public <init>(, , int);
}
-keepclassmembers class * extends {
public void *();
}
-keepclassmembers enum * { -> Enumeration classes cannot be confused.
public static **[] values();
public static ** valueOf();
}
-keep class * implements { -> aidl file cannot be obfuscated.
public static final $Creator *;
}