Android项目混淆配置

·  阅读 916

安卓混淆配置demo

#android 官方混淆配置
###########优化精简代码###########
-optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*  #指定要启用和禁用的优化
-optimizationpasses 5  #压缩比率  0---7
-allowaccessmodification  #指定在预先处理中 类和类成员的访问性可能会扩大
-dontpreverify #指定不预先验证处理类文件
#-dontoptimize
-dontusemixedcaseclassnames  #指定不产生混合的情况下的类名称而混淆
-dontskipnonpubliclibraryclasses
-verbose

-keepattributes *Annotation*  #保持注解
-keep public class com.google.vending.licensing.ILicensingService
-keep public class com.android.vending.licensing.ILicensingService

-keepclasseswithmembernames class * {#指定不混淆所有的jni方法
    native <methods>;
}

-keepclassmembers public class * extends android.view.View {#所有View的 子类 及其getset方法都不混淆
   void set*(***);
   *** get*();
}

-keepclassmembers class * extends android.app.Activity {#所有的activity子类中 参数类型为view的方法
   public void *(android.view.View);
}

-keepclassmembers enum * { #不混淆枚举类型中的指定方法
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

-keep class * implements android.os.Parcelable { #不混淆Parcelable 子类及其Creator成员变量
  public static final android.os.Parcelable$Creator *;
}

-keepclassmembers class **.R$* {#不混淆R类里及其所有内部static类中的所有static变量字段
    public static <fields>;
}

-dontwarn android.support.** #不提示兼容库的错误警告


##################以上是安卓官方提供方法#########################
#######################个性化配置#######################
-libraryjars   D:/android-sdk-windows/platforms/android-22/android.jar
-keep public class * extends com.wobo.live.app.WboBean{*;}
#-keep public class * extends com.wobo.live.app.model.BaseModel
-keep public class com.wobo.live.greendao.generator.**{*;}
-keepclassmembers class * extends com.android.frame.VLModel {
  	public protected <fields>;
    public protected <methods>;
}
-keepclassmembers class com.xiu8.android.room.RoomExerciseDialog$AppAndroid {
  public *;
}


-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
-keepattributes Signature
-keepattributes *JavascriptInterface*
-dontoptimize
-dontpreverify
-dontwarn cn.jpush.**
-keep class cn.jpush.** { *; }

######################第三方lib混淆配置#####################
#极光推送
-libraryjars libs/jpush-android-2.1.3.jar
-dontwarn com.google.**
-keep class com.google.protobuf.** {*;}
-dontwarn cn.jpush.**
-keep class cn.jpush.** { *; }

#谷歌gson
-libraryjars ../WFrame/libs/gson-1.7.1.jar
-dontwarn com.google.gson.**
-keep class com.google.gson.** {*;}
#-keep class com.google.**{*;}
#-keep class sun.misc.Unsafe { *; }
-keep class com.google.gson.stream.** { *; }
-keep class com.google.gson.examples.android.model.** { *; }
-keep class com.google.** {
    <fields>;
    <methods>;
}
-keepclassmembers class * implements java.io.Serializable {
    static final long serialVersionUID;
    private static final java.io.ObjectStreamField[] serialPersistentFields;
    private void writeObject(java.io.ObjectOutputStream);
    private void readObject(java.io.ObjectInputStream);
    java.lang.Object writeReplace();
    java.lang.Object readResolve();
}

#友盟统计  暂时没有
####################umeng##################
#-libraryjars libs/umeng-analytics-v5.2.4.jar
#-keep class com.umeng.analytics.** {*;}
#-dontwarn com.umeng.analytics.**
#-keep class com.umeng.** { *; }
#-keep class com.umeng.analytics.** { *; }
#-keep class com.umeng.common.** { *; }
#-keep class com.umeng.newxp.** { *; }
#-keepclassmembers class * {
#   public <init>(org.json.JSONObject);
#}
#-keep class com.umeng.**
#-keep public class com.idea.fifaalarmclock.app.R$*{
#    public static final int *;
#}
#-keep public class com.umeng.fb.ui.ThreadView {
#}
#-dontwarn com.umeng.**
#-dontwarn org.apache.commons.**
#-keep public class * extends com.umeng.**
#-keep class com.umeng.** {*; }

#支付宝相关
-libraryjars libs/alipaySDK-20150610.jar
-dontwarn com.alipay.**
-dontwarn com.ta.utdid2.**
-dontwarn com.ut.device.**
-keep class com.alipay.**
-keep class com.ta.utdid2.**
-keep class com.ut.device.**
#-dontwarn com.alipay.apmobilesecuritysdk.face**
#-keep class com.alipay.apmobilesecuritysdk.face.**{*;}
#
#-keep class com.alipay.android.app.IAlixPay{*;}
#-keep class com.alipay.android.app.IAlixPay$Stub{*;}
#-keep class com.alipay.android.app.IRemoteServiceCallback{*;}
#-keep class com.alipay.android.app.IRemoteServiceCallback$Stub{*;}
#-keep class com.alipay.sdk.app.PayTask{ public *;}
#-keep class com.alipay.sdk.app.AuthTask{ public *;}


# WFrame工程 异步Http
-libraryjars ../WFrame/libs/android-async-http-1.4.6.jar
-dontwarn com.loopj.android.**
-keep class com.loopj.android.**{*;}

# WFrame工程 imageLoader图片加载
-libraryjars ../WFrame/libs/universal-image-loader-1.9.3-SNAPSHOT.jar
-dontwarn com.nostra13.universalimageloader.**
-keep class  com.nostra13.universalimageloader.cache.** {*;}
-keep class  com.nostra13.universalimageloader.core.** {*;}
-keep class  com.nostra13.universalimageloader.utils.** {*;}

# WFrame工程 腾讯相关
-libraryjars ../WFrame/libs/libammsdk.jar
-dontwarn com.tencent.mm.**
-keep class com.tencent.mm.** {*;}

# WFrame工程 腾讯相关
-libraryjars ../WFrame/libs/mta-sdk-1.6.2.jar
-dontwarn com.tencent.stat.**
-keep class com.tencent.stat.**{*;}

# WFrame工程 腾讯相关
-libraryjars ../WFrame/libs/open_sdk_r5509.jar
-dontwarn com.tencent.**
-keep class com.tencent.** {*;}

# WFrame工程 下载相关
-libraryjars ../WFrame/libs/download-library-0.2.7.jar
-dontwarn com.liulishuo.filedownloader.**
-keep class com.liulishuo.filedownloader.** {*;}

#WFrame工程 OKIO相关
-libraryjars ../WFrame/libs/okio-1.6.0.jar
-dontwarn okio.**
-keep class okio.** {*;}

# WFrame工程 OKhttp相关
-libraryjars ../WFrame/libs/okhttp-3.1.2.jar
-dontwarn okhttp3.**
-keep class okhttp3.** {*;}

# WFrame工程 ant相关 中文解压
-libraryjars ../WFrame/libs/ant.jar
-dontwarn org.apache.tools.zip.**
-keep class org.apache.tools.zip.** {*;}


#金山lib
-libraryjars libs/libksystat.jar
-dontwarn com.ksy.statlibrary.**
-keep class com.ksy.statlibrary.**{*;}
#金山lib
-libraryjars libs/ksylive3.0.jar
-dontwarn com.ksy.recordlib.service.**
-keep class com.ksy.recordlib.service.** {*;}
#金山lib
-libraryjars libs/libksyplayer.jar
-dontwarn com.ksyun.media.player.**
-keep class com.ksyun.media.player.** {*;}

#新浪微博
-libraryjars libs/weibosdkcore_release.jar
-dontwarn com.sina.**
-keep class com.sina.**{*;}

# WFrame百度登录
-libraryjars ../WFrame/libs/baidu-android-openapi-sdk.jar
-dontwarn com.baidu.**
-keep class com.baidu.**{*;}

#greendao lib
-libraryjars libs/greendao-2.2.0.jar
-dontwarn de.greenrobot.dao.**
-keep class de.greenrobot.dao.** {*;}

#socketio lib
-libraryjars libs/socketio.jar
-dontwarn io.socket.**
-dontwarn org.java_websocket.**
-keep class io.socket.** {*;}
-keep class org.java_websocket.** {*;}

#加密相关 lib
-libraryjars libs/zhibohttpcommon.jar
-dontwarn zhibo.common.tools.**
-keep class zhibo.common.tools.** {*;}

复制代码
收藏成功!
已添加到「」, 点击更改