美文网首页
代码混淆

代码混淆

作者: 泡沫苏打 | 来源:发表于2017-11-21 14:16 被阅读0次
    # Add project specific ProGuard rules here.
    # By default, the flags in this file are appended to flags specified
    # in D:\android-sdk-windows/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 *;
    #}
    # copyright zhonghanwen
    #---------------------------------基本不用动区域----------------------------
    #---------------------------------基本指令区----------------------------------
    -optimizationpasses 5
    -dontusemixedcaseclassnames
    -dontskipnonpubliclibraryclasses
    -dontskipnonpubliclibraryclassmembers
    -dontpreverify
    -verbose
    -printmapping proguardMapping.txt
    -optimizations !code/simplification/cast,!field/*,!class/merging/*
    -keepattributes *Annotation*,InnerClasses
    -keepattributes Signature
    -keepattributes SourceFile,LineNumberTable
    #----------------------------------------------------------------------------
    
    #---------------------------------默认保留区---------------------------------
    #继承activity,application,service,broadcastReceiver,contentprovider....不进行混淆
    -keep public class * extends android.app.Activity
    -keep public class * extends android.app.Application
    -keep public class * extends android.support.multidex.MultiDexApplication
    -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 * extends android.view.View
    -keep public class com.android.vending.licensing.ILicensingService
    -keep class android.support.** {*;}
    
    -keep public class * extends android.view.View{
    *** get*();
    void set*(***);
       public <init>(android.content.Context);
       public <init>(android.content.Context, android.util.AttributeSet);
       public <init>(android.content.Context, android.util.AttributeSet, int);
    }
    -keepclasseswithmembers class * {
       public <init>(android.content.Context, android.util.AttributeSet);
       public <init>(android.content.Context, android.util.AttributeSet, int);
    }
    #这个主要是在layout 中写的onclick方法android:onclick="onClick",不进行混淆
    -keepclassmembers class * extends android.app.Activity {
       public void *(android.view.View);
    }
    
    -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();
    }
    -keep class **.R$* {
       *;
    }
    
    -keepclassmembers class * {
        void *(*Event);
    }
    
    -keepclassmembers enum * {
        public static **[] values();
        public static ** valueOf(java.lang.String);
    }
    -keep class * implements android.os.Parcelable {
      public static final android.os.Parcelable$Creator *;
    }
    #// natvie 方法不混淆
    -keepclasseswithmembernames class * {
        native <methods>;
    }
    
    #保持 Parcelable 不被混淆
    -keep class * implements android.os.Parcelable {
      public static final android.os.Parcelable$Creator *;
    }
    #----------------------------------------------------------------------------
    
    #---------------------------------webview------------------------------------
    -keepclassmembers class fqcn.of.javascript.interface.for.Webview     {
       public *;
    }
    -keepclassmembers class * extends     android.webkit.WebViewClient {
        public void *(android.webkit.WebView, java.lang.String,     android.graphics.Bitmap);
        public boolean *(android.webkit.WebView, java.lang.String);
    }
    -keepclassmembers class * extends android.webkit.WebViewClient {
        public void *(android.webkit.WebView, jav.lang.String);
    }
    #----------------------------------------------------------------------------
    #---------------------------------------------------------------------------------------------------
    #---------------------------------实体类---------------------------------
    修改成你对应的包名
    -keep class [your_pkg].** { *; }
    
    #---------------------------------第三方包-------------------------------
    
    #支付宝支付
    -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 *;}
    -keep public class * extends android.os.IInterface
    #微信支付
    -keep class com.tencent.mm.sdk.openapi.WXMediaMessage {*;}
    -keep class com.tencent.mm.sdk.openapi.** implements com.tencent.mm.sdk.openapi.WXMediaMessage$IMediaObject {*;}
    -keep class com.tencent.wxop.** { *; }
    -dontwarn com.tencent.mm.**
    -keep class com.tencent.mm.**{*;}
    -keepclasseswithmembernames class ** {}
    -keepattributes Signature
    
    -keep class sun.misc.Unsafe { *; }
    
    -keep class com.taobao.** {*;}
    -keep class com.alibaba.** {*;}
    -keep class com.alipay.** {*;}
    -dontwarn com.taobao.**
    -dontwarn com.alibaba.**
    -dontwarn com.alipay.**
    
    -keep class com.ut.** {*;}
    -dontwarn com.ut.**
    
    -keep class com.ta.** {*;}
    -dontwarn com.ta.**
    
    -keep class anet.**{*;}
    -keep class org.android.spdy.**{*;}
    -keep class org.android.agoo.**{*;}
    -dontwarn anet.**
    -dontwarn org.android.spdy.**
    -dontwarn org.android.agoo.**
    
    -keepclasseswithmembernames class com.xiaomi.**{*;}
    -keep public class * extends com.xiaomi.mipush.sdk.PushMessageReceiver
    
    -dontwarn com.xiaomi.push.service.b
    
    -keep class org.apache.http.**
    -keep interface org.apache.http.**
    -dontwarn org.apache.**
    
    #okhttp3
    -dontwarn okhttp3.**
    -keep class okhttp3.**{*;}
    
    #okio
    -dontwarn okio.**
    -keep class okio.**{*;}
    
    #sharesdk
    -keep class cn.sharesdk.**{*;}
    -keep class com.sina.**{*;}
    -keep class **.R$* {*;}
    -keep class **.R{*;}
    
    -keep class com.mob.**{*;}
    -dontwarn com.mob.**
    -dontwarn cn.sharesdk.**
    -dontwarn **.R$*
    
    ## nineoldandroids-2.4.0.jar
    -keep public class com.nineoldandroids.** {*;}
    
    ####################zxing#####################
    -keep class com.google.zxing.** {*;}
    -dontwarn com.google.zxing.**
    ##百度定位
    -keep class com.baidu.** {*;}
    -keep class vi.com.** {*;}
    -dontwarn com.baidu.**
    
    ## okhttp
    -dontwarn com.squareup.okhttp.**
    -keep class com.squareup.okhttp.{*;}
    #retrofit
    -dontwarn retrofit.**
    -keep class retrofit.** { *; }
    -keepattributes Signature
    -keepattributes Exceptions
    -dontwarn okio.**
    
    #recyclerview-animators
    -keep class jp.wasabeef.** {*;}
    -dontwarn jp.wasabeef.*
    
    #multistateview
    -keep class com.kennyc.view.** { *; }
    -dontwarn com.kennyc.view.*
    
    # universal-image-loader 混淆
    -dontwarn com.nostra13.universalimageloader.**
    -keep class com.nostra13.universalimageloader.** { *; }
    
    #ormlite
    -keep class com.j256.**
    -keepclassmembers class com.j256.** { *; }
    -keep enum com.j256.**
    -keepclassmembers enum com.j256.** { *; }
    -keep interface com.j256.**
    -keepclassmembers interface com.j256.** { *; }
    #umeng
    # ========= 友盟 =================
    -dontshrink
    -dontoptimize
    -dontwarn com.google.android.maps.**
    -dontwarn android.webkit.WebView
    -dontwarn com.umeng.**
    -dontwarn com.tencent.weibo.sdk.**
    -dontwarn com.facebook.**
    
    
    -keep enum com.facebook.**
    -keepattributes Exceptions,InnerClasses,Signature
    -keepattributes *Annotation*
    -keepattributes SourceFile,LineNumberTable
    
    -keep public interface com.facebook.**
    -keep public interface com.tencent.**
    -keep public interface com.umeng.socialize.**
    -keep public interface com.umeng.socialize.sensor.**
    -keep public interface com.umeng.scrshot.**
    
    -keep public class com.umeng.socialize.* {*;}
    -keep public class javax.**
    -keep public class android.webkit.**
    
    -keep class com.facebook.**
    -keep class com.umeng.scrshot.**
    -keep public class com.tencent.** {*;}
    -keep class com.umeng.socialize.sensor.**
    
    -keep class com.tencent.mm.sdk.modelmsg.WXMediaMessage {*;}
    
    -keep class com.tencent.mm.sdk.modelmsg.** implements   com.tencent.mm.sdk.modelmsg.WXMediaMessage$IMediaObject {*;}
    
    -keep class im.yixin.sdk.api.YXMessage {*;}
    -keep class im.yixin.sdk.api.** implements im.yixin.sdk.api.YXMessage$YXMessageData{*;}
    下面中括号的地方需要要填你的包名
    -keep public class [your_pkg].R$*{
        public static final int *;
    }
    -keepclassmembers class * {
       public <init> (org.json.JSONObject);
    }
    -keepclassmembers enum * {
        public static **[] values();
        public static ** valueOf(java.lang.String);
    }
    
    #友盟自动更新
    -keep public class com.umeng.fb.ui.ThreadView {}
    -keep public class * extends com.umeng.**
    # 以下包不进行过滤
    -keep class com.umeng.** { *; }
    
    
    #-ButterKnife 7.0
     -keep class butterknife.** { *; }
     -dontwarn butterknife.internal.**
     -keep class **$$ViewBinder { *; }
     -keepclasseswithmembernames class * {
          @butterknife.* <fields>;
     }
     -keepclasseswithmembernames class * {
          @butterknife.* <methods>;
     }
    
    
    #AndFix
    -keep class * extends java.lang.annotation.Annotation
    -keepclasseswithmembernames class * {
        native <methods>;
    }
    
    #eventbus 3.0
    -keepattributes *Annotation*
    -keepclassmembers class ** {
        @org.greenrobot.eventbus.Subscribe <methods>;
    }
    -keep enum org.greenrobot.eventbus.ThreadMode { *; }
    -keepclassmembers class * extends org.greenrobot.eventbus.util.ThrowableFailureEvent {
        <init>(java.lang.Throwable);
    }
    
    
    #EventBus
    -keepclassmembers class ** {
        public void onEvent*(**);
    }
    -keepclassmembers class ** {
        public void xxxxxx(**);
    }
    
    
    ################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.** { *; }
    
    -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();
    }
    -keep public class * implements java.io.Serializable {*;}
    
    
    # support-v4
    #https://stackoverflow.com/questions/18978706/obfuscate-android-support-v7-widget-gridlayout-issue
    -dontwarn android.support.v4.**
    -keep class android.support.v4.app.** { *; }
    -keep interface android.support.v4.app.** { *; }
    -keep class android.support.v4.** { *; }
    
    
    # support-v7
    -dontwarn android.support.v7.**
    -keep class android.support.v7.internal.** { *; }
    -keep interface android.support.v7.internal.** { *; }
    -keep class android.support.v7.** { *; }
    
    # support design
    #@link http://stackoverflow.com/a/31028536
    -dontwarn android.support.design.**
    -keep class android.support.design.** { *; }
    -keep interface android.support.design.** { *; }
    -keep public class android.support.design.R$* { *; }
    #-------------------------------------------------------------------------
    
    # picasso
    -keep class com.squareup.picasso.** {*; }
    -dontwarn com.squareup.picasso.**
    
    #glide
    -keep public class * implements com.bumptech.glide.module.GlideModule
    -keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** {
      **[] $VALUES;
      public *;
    }
    
    # #  ######## greenDao混淆  ##########
    # # -------------------------------------------
    -keep class de.greenrobot.dao.** {*;}
    -keepclassmembers class * extends de.greenrobot.dao.AbstractDao {
        public static Java.lang.String TABLENAME;
    }
    -keep class **$Properties
    # #  ############### volley混淆  ###############
    # # -------------------------------------------
    -keep class com.android.volley.** {*;}
    -keep class com.android.volley.toolbox.** {*;}
    -keep class com.android.volley.Response$* { *; }
    -keep class com.android.volley.Request$* { *; }
    -keep class com.android.volley.RequestQueue$* { *; }
    -keep class com.android.volley.toolbox.HurlStack$* { *; }
    -keep class com.android.volley.toolbox.ImageLoader$* { *; }
    
    #jpush极光推送
    -dontwarn cn.jpush.**
    -keep class cn.jpush.** { *; }
    
    #activeandroid
    -keep class com.activeandroid.** { *; }
    -dontwarn com.ikoding.app.biz.dataobject.**
    -keep public class com.ikoding.app.biz.dataobject.** { *;}
    -keepattributes *Annotation*
    
    #log4j
    -dontwarn org.apache.log4j.**
    -keep class org.apache.log4j.** { *;}
    #下面几行 是环信即时通信的代码混淆
    -keep class com.easemob.** {*;}
    -keep class org.jivesoftware.** {*;}
    -dontwarn com.easemob.**
    
    #融云
    -keepclassmembers class fqcn.of.javascript.interface.for.webview {
         public *;
    }
    
    -keepattributes Exceptions,InnerClasses
    
    -keep class io.rong.** {*;}
    
    -keep class * implements io.rong.imlib.model.MessageContent{*;}
    
    -keepattributes Signature
    
    -keepattributes *Annotation*
    
    -keep class sun.misc.Unsafe { *; }
    
    -keep class com.google.gson.examples.android.model.** { *; }
    
    -keepclassmembers class * extends com.sea_monster.dao.AbstractDao {
         public static java.lang.String TABLENAME;
    }
    -keep class **$Properties
    -dontwarn org.eclipse.jdt.annotation.**
    
    -keep class com.ultrapower.** {*;}
    #高徳地图
    -dontwarn com.amap.api.**
    -dontwarn com.a.a.**
    -dontwarn com.autonavi.**
    -keep class com.amap.api.**  {*;}
    -keep class com.autonavi.**  {*;}
    -keep class com.a.a.**  {*;}
    #----------------------------内部类------------------------------------------
    -keepclasseswithmembers class [包名.类名]$[类名] {
          <methods>;
    }
    #---------------------------------反射相关的类和方法-----------------------
    -keep class [your_pkg].** { *; }
    
    #---------------------------------与js互相调用的类------------------------
    在这下面写与js互相调用的类,没有就去掉这句话!
    
    #---------------------------------自定义View的类------------------------
    在这下面写自定义View的类的类,没有就去掉这句话!
    

    相关文章

      网友评论

          本文标题:代码混淆

          本文链接:https://www.haomeiwen.com/subject/iznzpxtx.html