android studio混淆

混淆代码如下:


#-----------------混淆配置设定------------------------------------------------------------------------
-optimizationpasses 5#指定代码压缩级别
-dontusemixedcaseclassnames                                                #混淆时不会产生形形色色的类名

-dontskipnonpubliclibraryclasses                                            #指定不忽略非公共类库

-dontpreverify                                                              #不预校验,如果需要预校验,是-dontoptimize

-ignorewarnings                                                            #屏蔽警告

-verbose                                                                    #混淆时记录日志

-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*#优化

#-----------------导入第三方包,但是在当前版本中使用会报 input jar file is specified twice 错误,所以注释掉

#-libraryjars libs/android.support.v4.jar

#-libraryjars libs/BaiduLBS_Android.jar

#-libraryjars libs/commons-httpclient-3.1.jar

#-libraryjars libs/jackson-annotations-2.1.4.jar

#-libraryjars libs/jackson-core-2.1.4.jar

#-libraryjars libs/jackson-databind-2.1.4.jar

#-libraryjars libs/xUtils-2.6.14.jar

#-----------------不需要混淆第三方类库------------------------------------------------------------------

-dontwarn android.support.v4.**#去掉警告

-keep class android.support.v4.** { *; }#过滤android.support.v4

-keep interface android.support.v4.app.** { *; }

-keep public class * extends android.support.v4.**

-keep public class * extends android.app.Fragment

-keep class org.apache.**{*;}#过滤commons-httpclient-3.1.jar

-keep class com.fasterxml.jackson.**{*;}#过滤jackson-core-2.1.4.jar等

-dontwarn com.lidroid.xutils.**#去掉警告

-keep class com.lidroid.xutils.**{*;}#过滤xUtils-2.6.14.jar

-keep class * extends java.lang.annotation.Annotation{*;}#这是xUtils文档中提到的过滤掉注解

#-dontwarn com.baidu.**                                                      #去掉警告

#-dontwarn com.baidu.mapapi.**

#-keep class com.baidu.** {*;}                                              #过滤BaiduLBS_Android.jar

#-keep class vi.com.gdi.bgl.android.**{*;}

#-keep class com.baidu.platform.**{*;}

#-keep class com.baidu.location.**{*;}

#-keep class com.baidu.vi.**{*;}

#-----------------------如果引用了v4或者v7包------------------------------------

  -dontwarn android.support.**

#------------------------JavaBean文件不混淆-----------------------------

  -keep class com.dwb.renrendaipai.model.** { *; }

#-------------------------eventbus混淆报错------------------

  -keep class de.greenrobot.event.** {*;}

-keepclassmembers class ** {

public void onEvent*(**);

void onEvent*(**);

  }

#-----------------不需要混淆系统组件等-------------------------------------------------------------------

-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.preference.Preference

-keep public class com.android.vending.licensing.ILicensingService

-keep class com.classtc.test.entity.**{*;}#过滤掉自己编写的实体类

#--------打包安装好运行闪退-------------------------

-dontwarn org.xmlpull.v1.XmlPullParser

-dontwarn org.xmlpull.v1.XmlSerializer

-keep class org.xmlpull.v1.* {*;}

-keepattributes *Annotation*

#-keepattributes Signature

-keep class **.R$* { *; }

#----------------保护指定的类和类的成员,但条件是所有指定的类和类成员是要存在------------------------------------

#-keepclasseswithmembernames class * {

#    public (android.content.Context, android.util.AttributeSet);

#}

#

#-keepclasseswithmembernames class * {

#    public (android.content.Context, android.util.AttributeSet, int);

#}

#-----------------友盟分享 混淆配置------------------------------------------------------------------

  -dontusemixedcaseclassnames

-dontshrink

-dontoptimize

    -dontwarn com.google.android.maps.**

-dontwarn android.webkit.WebView

-dontwarn com.umeng.**

-dontwarn com.tencent.weibo.sdk.**

-dontwarn com.facebook.**

-keep public class javax.**

-keep public class android.webkit.**

-dontwarn android.support.v4.**

-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 class com.android.dingtalk.share.ddsharemodule.** { *; }

-keep public class com.umeng.socialize.* {*;}

-keep class com.facebook.**

-keep class com.facebook.** { *; }

-keep class com.umeng.scrshot.**

-keep public class com.tencent.** {*;}

-keep class com.umeng.socialize.sensor.**

-keep class com.umeng.socialize.handler.**

-keep class com.umeng.socialize.handler.*

-keep class com.umeng.weixin.handler.**

-keep class com.umeng.weixin.handler.*

-keep class com.umeng.qq.handler.**

-keep class com.umeng.qq.handler.*

-keep class UMMoreHandler{*;}

-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 class com.tencent.mm.sdk.** {

*;

    }

-keep class com.tencent.mm.opensdk.** {

*;

    }

-dontwarn twitter4j.**

-keep class twitter4j.** { *; }

-keep class com.tencent.** {*;}

-dontwarn com.tencent.**

-keep public class com.umeng.com.umeng.soexample.R$*{

public static final int *;

    }

-keep public class com.linkedin.android.mobilesdk.R$*{

public static final int *;

        }

-keepclassmembers enum * {

public static **[] values();

public static ** valueOf(java.lang.String);

    }

-keep class com.tencent.open.TDialog$*

-keep class com.tencent.open.TDialog$* {*;}

-keep class com.tencent.open.PKDialog

-keep class com.tencent.open.PKDialog {*;}

-keep class com.tencent.open.PKDialog$*

-keep class com.tencent.open.PKDialog$* {*;}

-keep class com.sina.** {*;}

-dontwarn com.sina.**

-keep class  com.alipay.share.sdk.** {

*;

    }

-keepnames class * implements android.os.Parcelable {

public static final ** CREATOR;

    }

-keep class com.linkedin.** { *; }

-keepattributes Signature

#    ------------------------------------------连连混淆---------------------------------------------

# 连连混淆keep规则

-keep public class com.yintong.** {

;

;

}

-keepclasseswithmembernames class * {

native ;

}

-keepclassmembers public class * extends android.view.View {

void set*(***);

*** get*();

}

-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 *;

}

#-------------------------------------支付宝支付 混淆-----------------------------------

# -libraryjars libs/alipaySDK-20161222.jar

    -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 *;}

#-------------------------------------- 微信支付 混淆------------------------------------

#  -libraryjars libs/libammsdk.jar

    -keep class com.tencent.** { *;}

#----------------------------------------极光推送 混淆-------------------------------------------------

    -dontoptimize

-dontpreverify

    -dontwarn cn.jpush.**

-keep class cn.jpush.** { *; }

-dontwarn cn.jiguang.**

-keep class cn.jiguang.** { *; }

#==================gson && protobuf==========================

    -dontwarn com.google.**

-keep class com.google.gson.** {*;}

-keep class com.google.protobuf.** {*;}

## ----------------------------------

##      OkHttp相关

## ----------------------------------

    -keepattributes Signature

-keepattributes *Annotation*

-keep class com.squareup.okhttp3.** { *; }

-keep interface com.squareup.okhttp3.** { *; }

-dontwarn com.squareup.okhttp3.**

## ----------------------------------

##      Okio相关

## ----------------------------------

    -keep class sun.misc.Unsafe { *; }

-dontwarn java.nio.file.*

-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement

-dontwarn okio.**

## ----------------------------------

##      Glide相关

## ----------------------------------

    -keep class com.bumptech.glide.Glide { *; }

-keep public class * implements com.bumptech.glide.module.GlideModule

-keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** {

**[] $VALUES;

public *;

    }

-dontwarn com.bumptech.glide.**

#阿里sophix热修复

#基线包使用,生成mapping.txt

-printmapping mapping.txt

#生成的mapping.txt在app/buidl/outputs/mapping/release路径下,移动到/app路径下

#修复后的项目使用,保证混淆结果一致

#-applymapping mapping.txt

#hotfix

-keep class com.taobao.sophix.**{*;}

-keep class com.ta.utdid2.device.**{*;}

#防止inline

-dontoptimize

    #高德定位

    -keep class com.amap.api.location.**{*;}

-keep class com.amap.api.fence.**{*;}

-keep class com.autonavi.aps.amapapi.model.**{*;}

具体错误忘记包含xml字段错误修改方法如下

image

jar包EventBus报错 实体类被混淆修改方法如下

image

项目实体类被混淆修改如下

image

你可能感兴趣的:(android studio混淆)