1. Eclipse 打开需要打包的项目根目录project.properties文件:如图
2.然后将这句话加入进去
proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
3.更改项目所引用的SDK中的一个文件
(D:\Tools\android-sdk-windows\tools\proguard)这个是我的sdk的路径打开如图文件
打开是这样的:
然后在后面加上如下图中的几行文字
改好之后,混淆代码,防止编译的步骤也到此结束,在做这些东西前,注意备份!!*_*
下面是proguard-android文件中的全部内容:
# This is a configuration file for ProGuard. # http://proguard.sourceforge.net/index.html#manual/usage.html
-dontusemixedcaseclassnames -dontskipnonpubliclibraryclasses -verbose
# Optimization is turned off by default. Dex does not like code run # through the ProGuard optimize and preverify steps (and performs some # of these optimizations on its own). -dontoptimize -dontpreverify # Note that if you want to enable optimization, you cannot just # include optimization flags in your own project configuration file; # instead you will need to point to the # "proguard-android-optimize.txt" file instead of this one from your # project.properties file.
-keepattributes *Annotation* -keep public class com.google.vending.licensing.ILicensingService -keep public class com.android.vending.licensing.ILicensingService
# For native methods, see http://proguard.sourceforge.net/manual/examples.html#native -keepclasseswithmembernames class * { native <methods>; }
# keep setters in Views so that animations can still work. # see http://proguard.sourceforge.net/manual/examples.html#beans -keepclassmembers public class * extends android.view.View { void set*(***); *** get*(); }
# We want to keep methods in Activity that could be used in the XML attribute onClick -keepclassmembers class * extends android.app.Activity { public void *(android.view.View); }
# For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations -keepclassmembers enum * { public static **[] values(); public static ** valueOf(java.lang.String); }
-keep class * implements android.os.Parcelable { public static final android.os.Parcelable$Creator *; }
-keepclassmembers class **.R$* { public static <fields>; }
# The support library contains references to newer platform versions. # Don't warn about those in case this app is linking against an older # platform version. We know about them, and they are safe. -dontwarn android.support.**
# ------ 编译时需要用到的 jar 包 -libraryjars E:\workspace for android\kaicheba_student_1.0\libs\alipaySDK-20151014.jar -libraryjars E:\workspace for android\kaicheba_student_1.0\libs\BaiduLBS_Android.jar -libraryjars E:\workspace for android\kaicheba_student_1.0\libs\android-support-v4.jar -libraryjars E:\workspace for android\kaicheba_student_1.0\libs\core-3.1.0.jar -libraryjars E:\workspace for android\kaicheba_student_1.0\libs\gson-2.2.2.jar -libraryjars E:\workspace for android\kaicheba_student_1.0\libs\jpush-sdk-release1.8.2.jar -libraryjars E:\workspace for android\kaicheba_student_1.0\libs\libammsdk.jar -libraryjars E:\workspace for android\kaicheba_student_1.0\libs\ShareSDK-Wechat-Core-2.6.1.jar -libraryjars E:\workspace for android\kaicheba_student_1.0\libs\universal-image-loader-1.9.3.jar
# ------ 保护百度地址jar包 -------- -keep class com.baidu.mapapi.** { *; } -dontwarn com.baidu.mapapi.** #Wechat-Core-2.6.1.jar.jar
# ------ 保护分享jar包 -------- -keep class cn.sharesdk.wechat.utils.** { *; } -dontwarn cn.sharesdk.wechat.utils.**
-dontwarn com.taobao.dp.** -keep class com.taobao.dp.** { *;}
-dontwarn cn.jpush.android.** -keep class cn.jpush.android.** { *;} |
做完这些工作就可以签名打包了,然后可以使用ApkDec进行反编译,用jd-gui检验自己做的防止反编译的工作是否成功,是否可以不被查看到源代码!