Android's code obfuscation is a knowledge that developers need to know to prevent anti-compilation of Android apps. Because most Android programs are developed in the Java language, and Java code is easy to decompile, the confuse right of Android code is often necessary in order to apply certain security to the Android application code.
Learn about the anti-compilation of Android before you understand the code obfuscation. The anti-compilation of Android requires two tools Dex2jar and Jd-gui.
1. Anti-compilation of code
After the two tools are ready, unzip the apk file directly. In the extracted file, copy the Classes.dex to the Dex2jar folder. Input command:dex2jar.bat classes.dex , enter. Classes_dex2jar compressed files are generated in the Dex2jar folder. Open the file with Jd-gui to see the source code for the Android app.
2. Code obfuscation
Add proguard.cfg. File to Android project. Add Proguard.config=proguard.cfg to Project.Properties.
-ignorewarnings-libraryjars libs/android-support-v4.jar-libraryjars libs/gson-2.2.4.jar-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 Androi D.content.broadcastreceiver-keep public class * extends Android.content.contentprovider-keep public class Com.android.vending.licensing.ilicensingservice-keepclasseswithmembernames class * {native<Methods>;} -keepclasseswithmembernames class * { public<Init>(Android.content.Context, android.util.AttributeSet);} -keepclasseswithmembernames class * { public<Init>(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 *;}proguard.cfg
3. Project Packaging
Right-click Project, select Androidtools-export unsinged application package. Decompile the packaged apk.
As you can see, the code has been compiled. The unsigned apk package is not able to be installed, and you need to sign the APK.
Android Simple Code obfuscation