转载地址:http://blog.csdn.net/wangbofei/article/details/8266553
参考博客地址:
http://hubingforever.blog.163.com/blog/static/171040579201342982553107/
http://blog.csdn.net/wotoumingzxy/article/details/8279646
http://www.cnblogs.com/sunzn/archive/2013/03/06/2946952.html
http://blog.csdn.net/atrueman123/article/details/6281658
一、理论知识
在Android应用程序也可以使用
在使用Eclipse新建一个工程,都会在工程目录下生产配置project.properties和proguard-project.tx。
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt # Project target. target=android-10
proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
------------------------------------------------------------------------------------------------------------------------------------------
下面是混淆打包第三方jar包的处理:
在project.properties里加上 proguard.config=proguard.cfg
proguard.cfg 配置如下:
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
#忽略警告 也可以用-ignorewarnings
-dontwarn
#声明第三方jar包,不用管第三方jar包中的.so文件(如果有)
-libraryjars libs/baidumapapi.jar
-libraryjars libs/tencent_openapi.jar
-libraryjars libs/httpmime-4.1.3.jar
-libraryjars libs/weibo.sdk.android.sso.jar
-libraryjars libs/android-support-v4.jar
-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 *;
}
#不混淆第三方jar包中的类
-keep class com.baidu.mapapi.** {*;}
-keep class com.tencent.tauth.** {*;}
-keep class org.apache.http.entity.mime.** {*;}
-keep class android.support.v4.** {*;}
-keep class android.net.http.** {*;}
-keep class com.weibo.sdk.android.** {*;}
-keep class com.sina.sso.** {*;}
说明一下,第三方jar包中如果有.so文件,不用去理会,引入的第三方jar文件不要混淆,否则可能会报异常