使用Android混淆器proguard.cfg来防止程序被反编译,也其实就是将变量的名称混淆一下,降低程序的可读性
使用步骤:
1.default.properties文件中添加一行proguard.config=proguard.cfg, 例如以下是我的default.properties的源文件
# 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-8proguard.config=proguard.cfg
2.将SDK路径中的D:\android-sdk-windows\tools\lib\proguard.cfg复制到项目的根目录下面即可,以下的proguard.cfg文件是我直接从sdk的根目录拷贝过来的,源码如下:
-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 *;
}
完成, proguard.cfg是可以配置很多参数的,就不介绍了..这样就可以达到混淆代码了...