这里贴一份目前正在使用的混淆规则:
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/yfc/android/studio_SDK/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
#############################################
# 代码混淆压缩比,在0~7之间,默认为5,一般不做修改
-verbose
-optimizationpasses 5
# 混合时不使用大小写混合,混合后的类名为小写
-dontusemixedcaseclassnames
# 混淆时是否做预校验
-dontpreverify
# 指定不去忽略非公共库的类
-dontskipnonpubliclibraryclasses
# 指定不去忽略非公共库的类成员
-dontskipnonpubliclibraryclassmembers
# 混淆时所采用的算法
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
# 避免混淆泛型
-keepattributes Signature
# 抛出异常时保留代码行号
-keepattributes SourceFile,LineNumberTable
#保持 native static 方法不被混淆
-keep public class * {
native <methods>;
static <methods>;
}
# 保留support下的所有类及其内部类
-keep class android.support.** {*;}
-dontwarn android.support.**
# 保留bolts下的所有类及其内部类
-keep class bolts.** {*;}
-dontwarn bolts.**
# 保留fastjson下的所有类及其内部类
-keep class com.alibaba.fastjson.** {*;}
-dontwarn com.alibaba.fastjson.**
# 保留com.android.vending.billing下的所有类及其内部类
-keep class com.android.vending.billing.** {*;}
-dontwarn com.android.vending.billing.**
# 保留applovin下的所有类及其内部类
-keep class com.applovin.** {*;}
-dontwarn com.applovin.**
# 保留appsflyer下的所有类及其内部类
-keep class com.appsflyer.** {*;}
-dontwarn com.appsflyer.**
# 保留avos下的所有类及其内部类
-keep class com.avos.** {*;}
-dontwarn com.avos.**
# 保留avoscloud下的所有类及其内部类
-keep class com.avoscloud.** {*;}
-dontwarn com.avoscloud.**
# 保留avoscloud_gcm下的所有类及其内部类
-keep class com.avoscloud_gcm.** {*;}
-dontwarn com.avoscloud_gcm.**
# 保留chartboost下的所有类及其内部类
-keep class com.chartboost.** {*;}
-dontwarn com.chartboost.**
# 保留facebook下的所有类及其内部类
-keep class com.facebook.** {*;}
-dontwarn com.facebook.**
# 保留flurry下的所有类及其内部类
-keep class com.flurry.** {*;}
-dontwarn com.flurry.**
# 保留google下的所有类及其内部类
-keep class com.google.** {*;}
-dontwarn com.google.**
# 保留picasso下的所有类及其内部类
-keep class com.squareup.picasso.** {*;}
-dontwarn com.squareup.picasso.**
# 保留bugly下的所有类及其内部类
-keep class com.tencent.bugly.** {*;}
-dontwarn com.tencent.bugly.**
# 保留unity3d下的所有类及其内部类
-keep class com.unity3d.ads.** {*;}
-dontwarn com.unity3d.ads.**
# 保留httpclient下的所有类及其内部类
-keep class cz.msebera.** {*;}
-dontwarn cz.msebera.**
# 保留async http下的所有类及其内部类
-keep class com.loopj.android.http.** {*;}
-dontwarn com.loopj.android.http.**
-keep class android.net.**{*;}
-dontwarn android.net.**
-keep class org.apache.http.** {*;}
-dontwarn org.apache.http.**
-keep class org.cocos2dx.** {*;}
-dontwarn org.cocos2dx.**