As an Android app developer, you have to face an embarrassing situation: applications that have worked hard to develop can be decompiled easily by others. Google also seems to have discovered this problem. From sdk2.3, we can see that a proguard folder is added under Android-SDK-Windows/tools/, and proguard is a Java code obfuscation tool, with proguard, even if you decompile your APK package, you will only see some ugly code to protect the code.
Let's talk about how to make the proguard. cfg file under sdk2.3 take a look at the content of proguard. cfg:
-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 <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 *;}
As shown in the script, obfuscation retains the basic components inherited from activity, service, application, broadcastreceiver, contentprovider, and COM. android. vending. licensing. ilicensingservice, retains all native variable names and class names, And some of all classes Use constructors with fixed parameter formats, enumerations, and so on. (For more information, see examples and comments in <proguard_path>/examples .)
Make proguard. CFG works very easily, that is, the default automatically generated in eclipse. add "proguard. config = proguard. CFG, complete default. the properties file should be as follows:
# This file is automatically generated by Android Tools.# Do not modify this file -- YOUR CHANGES WILL BE ERASED!## This file must be checked in Version Control Systems.## To customize properties used by the Ant build system use,# "build.properties", and override values to adapt the script to your# project structure.# Project target.target=android-9proguard.config=proguard.cfg
After the signature is compiled properly, the code can be decompiled. The Code produced by the decompiled APK after code obfuscation should be similar to the following, which is hard to understand:
If you are using an SDK version earlier than 2.3, copy the above proguard. cfg file to the project and perform the same operation.