Android code obfuscation notes
After the apk for obfuscation is decompiled, the name and class names in the Code are changed to abcd, which is hard to understand.
Use code obfuscation, enable obfuscators, edit related files, and then package the signature;
------------
In Version 2.3, the project contains the file proguard. cfg (you can add it manually if not)
Add: proguard. config = proguard. cfg
Content in the proguard. cfg file:
-optimizationpasses 5-dontusemixedcaseclassnames-dontskipnonpubliclibraryclasses-dontpreverify-verbose-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*-keep public class * extends android.app.Activity-keep public class * extends android.app.Application-keep public class * extends android.app.Service-keep public class * extends android.content.BroadcastReceiver-keep public class * extends android.content.ContentProvider-keep public class com.android.vending.licensing.ILicensingService-keepclasseswithmembernames class * { native
;}-keepclasseswithmembernames class * { public
(android.content.Context, android.util.AttributeSet);}-keepclasseswithmembernames class * { public
(android.content.Context, android.util.AttributeSet, int);}-keepclassmembers enum * { public static **[] values(); public static ** valueOf(java.lang.String);}-keep class * implements android.os.Parcelable { public static final android.os.Parcelable$Creator *;}
-------------------------
The project files are project.propertiesand proguard-project.txt.
Open project. properties and uncomment the following line of code:
Proguard. config =$ {sdk. dir}/tools/proguard/proguard-android.txt: proguard-project.txt
The default settings do not contain the optimization function. You can use the following settings to add the code optimization function:
# Proguard. config =$ {sdk. dir}/tools/proguard/proguard-android-optimize.txt: proguard-project.txt
-------------------------------------------------------
Some editing rules for proguard-project.txt files:
-Libraryjars libs/android-support-v4.jar
-Libraryjars libs: loads third-party Jar packages
-Ignorewarnings: Remove warnings from code
-Keep class com. xxx. xxx .**
-Keep: keep non-obfuscation classes
This type of public method is retained and not obfuscated.
-Keep class com. xx. xx. Test {
Public *;
}
Protects specified class files and Class Members
-Keep class * implements android. OS. Parcelable {
Public static final android. OS. Parcelable $ Creator *;
}
----------------------------------------------------
Use the Eclipse tool to package the signature:
In Eclipse, right-click the project and choose> Android Tools
---> Export Signed Application Package... with RSA Digital Signature
---> Export Unsigned Application Package... without a digital signature
Select a method to follow the Wizard. The generated Apk is obfuscated.
----------------------------------------