Http://blog.csdn.net/sunboy_2050/article/details/6727640
The author also has an article on how to decompile, which can be viewed at any time ~
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 there is a proguard folder under Android-SDK-Windows \ tools \.
Proguard is a Java code obfuscation tool. With proguard, even if you decompile your APK package, others 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 Android-SDK-Windows \ tools \ Lib \Proguard. cfgContent:
-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 * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService
-keepclasseswithmembernames class * {
native <methods>;
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
From the script, we can see that the obfuscation retains the basic components inherited from activity, service, application, broadcastreceiver, contentprovider, and COM. Android. Vending. Licensing. ilicensingservice,
All native variable names and class names are retained. All classes Use constructors with fixed parameter formats, such as enumeration. (For more information, see examples and comments in <proguard_path>/examples .)
It's easy to make proguard. cfg take effect. Add "proguard. Config = proguard. cfg" to the default. properties file automatically generated by eclipse.
The complete default. properties file should be as follows:
1. # This file is automatically generated by Android Tools.
2. # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3. #
4. # This file must be checked in Version Control Systems.
5. #
6. # To customize properties used by the Ant build system use,
7. # "build.properties", and override values to adapt the script to your
8. # project structure.
9.
10. # Project target.
11. target=android-9
12. proguardproguard.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.