From dd0704d3020e30565e79941e58c5c9f240386735 Mon Sep 17 00:00:00 2001 From: maning <154292322@qq.com> Date: Sun, 18 Oct 2020 17:55:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=B7=E6=B7=86=E6=96=87=E4=BB=B6=E6=9B=BF?= =?UTF-8?q?=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 7 +- app/{src/proguard.cfg => proguard-rules.pro} | 705 ++++++++++--------- 2 files changed, 386 insertions(+), 326 deletions(-) rename app/{src/proguard.cfg => proguard-rules.pro} (66%) mode change 100755 => 100644 diff --git a/app/build.gradle b/app/build.gradle index 49183e3..af08bea 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -69,7 +69,6 @@ android { exclude 'META-INF/maven/com.belerweb/pinyin4j/pom.properties' } - File customerproguardFile = file('src/proguard.cfg') buildTypes { release { //混淆 @@ -79,15 +78,15 @@ android { signingConfig signingConfigs.release //移除无用的资源文件 shrinkResources true - proguardFiles customerproguardFile.path buildConfigField "boolean", "LOG_DEBUG", "false" + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } debug { //混淆 - minifyEnabled false + minifyEnabled true signingConfig signingConfigs.release - proguardFiles customerproguardFile.path buildConfigField "boolean", "LOG_DEBUG", "true" + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } diff --git a/app/src/proguard.cfg b/app/proguard-rules.pro old mode 100755 new mode 100644 similarity index 66% rename from app/src/proguard.cfg rename to app/proguard-rules.pro index 6a682c7..38e3009 --- a/app/src/proguard.cfg +++ b/app/proguard-rules.pro @@ -1,322 +1,383 @@ -# This is a configuration file for ProGuard. -# http://proguard.sourceforge.net/index.html#manual/usage.html - --dontusemixedcaseclassnames --dontskipnonpubliclibraryclasses --verbose - --ignorewarnings - -# Optimization is turned off by default. Dex does not like code run -# through the ProGuard optimize and preverify steps (and performs some -# of these optimizations on its own). --dontoptimize --dontpreverify -# Note that if you want to enable optimization, you cannot just -# include optimization flags in your own project configuration file; -# instead you will need to point to the -# "proguard-android-optimize.txt" file instead of this one from your -# project.properties file. - --keepattributes *Annotation* --keep public class * extends android.app.Activity --keep public class * extends android.support.v4.app.Fragment --keep public class * extends android.app.TabActivity --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.google.vending.licensing.ILicensingService --keep public class com.android.vending.licensing.ILicensingService - -# For native methods, see http://proguard.sourceforge.net/manual/examples.html#native --keepclasseswithmembernames class * { - native ; -} - -# keep setters in Views so that animations can still work. -# see http://proguard.sourceforge.net/manual/examples.html#beans --keepclassmembers public class * extends android.view.View { - void set*(***); - *** get*(); -} - -# We want to keep methods in Activity that could be used in the XML attribute onClick --keepclassmembers class * extends android.app.Activity { - public void *(android.view.View); -} - -# For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations --keepclassmembers enum * { - public static **[] values(); - public static ** valueOf(java.lang.String); -} - --keep class * implements android.os.Parcelable { - public static final android.os.Parcelable$Creator *; -} - --keepclassmembers class **.R$* { - public static ; -} - -# The support library contains references to newer platform versions. -# Don't warn about those in case this app is linking against an older -# platform version. We know about them, and they are safe. --dontwarn android.support.** --keep class android.support.** {*;} - -#保持 native 方法不被混淆 --keepclasseswithmembernames class * { - native ; -} - -#R文件 --keep public class com.maning.gankmm.R$*{ - public static final int *; -} - -#保持行号 --keepattributes SourceFile,LineNumberTable - -# 不混淆第三方jar包中的类 --keep public class * extends android.support.v4.** {*;} --keep class com.alipay.** {*;} --keep class com.ta.** {*;} --keep class com.ut.** {*;} --keep class com.baidu.** {*;} --keep class com.alibaba.fastjson.** {*;} --keep class com.umeng.** {*;} --keep class org.apache.poi.** {*;} --keep class com.iflytek.** {*;} --keep class * extends java.lang.annotation.Annotation { *; } --keep class android.net.http.SslError --keep class android.webkit.**{*;} --keep class cn.sharesdk.**{*;} --keep class com.sina.**{*;} --keep class m.framework.**{*;} --keep public class com.idea.fifaalarmclock.app.R$*{ - public static final int *; -} --dontwarn org.apache.commons.** --dontwarn com.iflytek.** --keepattributes Signature - -#Umeng相关 --keep class com.umeng.** {*;} --dontwarn com.umeng.** --keep public class * extends com.umeng.** --keep public class com.umeng.fb.ui.ThreadView { -} --keepclassmembers class * { - public (org.json.JSONObject); -} --keepclassmembers enum * { - public static **[] values(); - public static ** valueOf(java.lang.String); -} -#Umeng在线参数 --keep class com.umeng.onlineconfig.OnlineConfigAgent { - public ; - public ; -} --keep class com.umeng.onlineconfig.OnlineConfigLog { - public ; - public ; -} --keep interface com.umeng.onlineconfig.UmengOnlineConfigureListener { - public ; -} - -#EventBus --keepclassmembers class ** { - public void onEvent*(**); - void onEvent*(**); -} -# 不混淆butterknife包下所有的类 --keep class butterknife.** { *; } --dontwarn butterknife.internal.** --keep class **$$ViewBinder { *; } --keepclasseswithmembernames class * { - @butterknife.* ; -} --keepclasseswithmembernames class * { - @butterknife.* ; -} -# # ------------------------------------------- -# # ######## picasso混淆 ########## -# # ------------------------------------------- --dontwarn com.squareup.okhttp.** --keep class com.squareup.** - -# # ------------------------------------------- -# # ######## fastJson混淆 ########## -# # ------------------------------------------- --dontwarn com.alibaba.fastjson.** --keep class com.alibaba.fastjson.** { *; } --keepclassmembers class * { - public ; -} - -## ---------------------------------- -## ########## Gson混淆 ########## -## ---------------------------------- --keepattributes Signature --keep class sun.misc.Unsafe { *; } --keep class com.google.gson.examples.android.model.** { *; } - -## ---------------------------------- -## ########## retrofit混淆 ########## -## ---------------------------------- --dontwarn retrofit.** --keep class retrofit.** { *; } --keepattributes Signature --keepattributes Exceptions - -## ---------------------------------- -## ########## ActiveAndroid ########## -## ---------------------------------- --keep class com.activeandroid.** { *; } --keep class com.activeandroid.**.** { *; } --keep class * extends com.activeandroid.Model --keep class * extends com.activeandroid.serializer.TypeSerializer - -## ---------------------------------- -## ########## 极光推送相关 ########## -## ---------------------------------- --dontoptimize --dontpreverify - --dontwarn cn.jpush.** --keep class cn.jpush.** { *; } - --dontwarn cn.jiguang.** --keep class cn.jiguang.** { *; } - -## ---------------------------------- -## ########## 微信混淆 ########## -## ---------------------------------- --dontwarn com.tencent.mm.** --keep class com.tencent.mm.** { *;} --keep class com.zhiketong.zkthotel.wxapi.** { *; } - -## ---------------------------------- -## ########## LeakCanary ########## -## ---------------------------------- --keep class org.eclipse.mat.** { *; } --keep class com.squareup.leakcanary.** { *; } - -## ---------------------------------- -## ########## AndFix ########## -## ---------------------------------- --printmapping mapping.txt -#-applymapping /Users/maning/Desktop/mapping.txt --keep class * extends java.lang.annotation.Annotation --keep class com.alipay.euler.andfix.** { *; } - -## ---------------------------------- -## ########## okhttp ########## -## ---------------------------------- --dontwarn okhttp3.** --keep class okhttp3.**{*;} --keep interface okhttp3.**{*;} -#okio --dontwarn okio.** --keep class okio.**{*;} --keep interface okio.**{*;} - -## ---------------------------------- -## ########## Glide ########## -## ---------------------------------- --keep public class * implements com.bumptech.glide.module.GlideModule --keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** { - **[] $VALUES; - public *; -} - -## ---------------------------------- -## ########## APP ########## -## ---------------------------------- --keep class com.maning.gankmm.bean.** {*;} --keep class com.maning.gankmm.utils.ACache { *; } - -## ---------------------------------- -## ########## Jsoup ########## -## ---------------------------------- --keep class org.jsoup.** {*;} - -## ---------------------------------- -## ########## 阿里反馈 ########## -## ---------------------------------- --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 com.alibaba.sdk.android.feedback.** {*;} - -## ---------------------------------- -## ########## 有米 ########## -## ---------------------------------- --keep public class android.support.**{ - *; -} - -## ---------------------------------- -## ########## 高德地图 ########## -## ---------------------------------- --keep class com.amap.api.location.**{*;} --keep class com.amap.api.fence.**{*;} --keep class com.autonavi.aps.amapapi.model.**{*;} - -#PictureSelector 2.0 --keep class com.luck.picture.lib.** { *; } - --dontwarn com.yalantis.ucrop** --keep class com.yalantis.ucrop** { *; } --keep interface com.yalantis.ucrop** { *; } - - #rxjava --dontwarn sun.misc.** --keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* { - long producerIndex; - long consumerIndex; -} --keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef { - rx.internal.util.atomic.LinkedQueueNode producerNode; -} --keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueConsumerNodeRef { - rx.internal.util.atomic.LinkedQueueNode consumerNode; -} - -#rxandroid --dontwarn sun.misc.** --keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* { - long producerIndex; - long consumerIndex; -} --keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef { - rx.internal.util.atomic.LinkedQueueNode producerNode; -} --keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueConsumerNodeRef { - rx.internal.util.atomic.LinkedQueueNode consumerNode; -} - -#glide --keep public class * implements com.bumptech.glide.module.GlideModule --keep public class * extends com.bumptech.glide.AppGlideModule --keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** { - **[] $VALUES; - public *; -} - - +# This is a configuration file for ProGuard. +# http://proguard.sourceforge.net/index.html#manual/usage.html + +##########################################################################默认配置 +#忽略警告 不忽略可能打包不成功 +-ignorewarnings + +# 代码混淆压缩比,在0~7之间,默认为5,一般不做修改 +-optimizationpasses 5 + +# 混合时不使用大小写混合,混合后的类名为小写 +-dontusemixedcaseclassnames + +# 指定不去忽略非公共库的类 +-dontskipnonpubliclibraryclasses + +# 这句话能够使我们的项目混淆后产生映射文件 +# 包含有类名->混淆后类名的映射关系 +-verbose + +# 指定不去忽略非公共库的类成员 +-dontskipnonpubliclibraryclassmembers + +# 不做预校验,preverify是proguard的四个步骤之一,Android不需要preverify,去掉这一步能够加快混淆速度。 +-dontpreverify + +# 保留Annotation不混淆 +-keepattributes *Annotation*,InnerClasses + +# 避免混淆泛型 +-keepattributes Signature + +# 抛出异常时保留代码行号 +-keepattributes SourceFile,LineNumberTable + +# 指定混淆是采用的算法,后面的参数是一个过滤器 +# 这个过滤器是谷歌推荐的算法,一般不做更改 +-optimizations !code/simplification/cast,!field/*,!class/merging/* + + +############################################# +# +# Android开发中一些需要保留的公共部分 +# +############################################# + +# 保留我们使用的四大组件,自定义的Application等等这些类不被混淆 +# 因为这些子类都有可能被外部调用 +-keep public class * extends android.app.Activity +-keep public class * extends android.app.Appliction +-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 + + +# 保留support下的所有类及其内部类 +-keep class android.support.** {*;} + +# 保留继承的 +-keep public class * extends android.support.v4.** +-keep public class * extends android.support.v7.** +-keep public class * extends android.support.annotation.** + +#androidx包使用混淆 +-keep class com.google.android.material.** {*;} +-keep class androidx.** {*;} +-keep public class * extends androidx.** +-keep interface androidx.** {*;} +-dontwarn com.google.android.material.** +-dontnote com.google.android.material.** +-dontwarn androidx.** + +# 保留R下面的资源 +-keep class **.R$* {*;} + +# 保留本地native方法不被混淆 +-keepclasseswithmembernames class * { + native ; +} + +# 保留在Activity中的方法参数是view的方法, +# 这样以来我们在layout中写的onClick就不会被影响 +-keepclassmembers class * extends android.app.Activity{ + public void *(android.view.View); +} + +# 保留枚举类不被混淆 +-keepclassmembers enum * { + public static **[] values(); + public static ** valueOf(java.lang.String); +} + +# 保留我们自定义控件(继承自View)不被混淆 +-keep public class * extends android.view.View{ + *** get*(); + void set*(***); + public (android.content.Context); + public (android.content.Context, android.util.AttributeSet); + public (android.content.Context, android.util.AttributeSet, int); +} + +# 保留Parcelable序列化类不被混淆 +-keep class * implements android.os.Parcelable { + public static final android.os.Parcelable$Creator *; +} + +# 保留Serializable序列化的类不被混淆 +-keepclassmembers class * implements java.io.Serializable { + static final long serialVersionUID; + private static final java.io.ObjectStreamField[] serialPersistentFields; + !static !transient ; + !private ; + !private ; + private void writeObject(java.io.ObjectOutputStream); + private void readObject(java.io.ObjectInputStream); + java.lang.Object writeReplace(); + java.lang.Object readResolve(); +} + +# 对于带有回调函数的onXXEvent、**On*Listener的,不能被混淆 +-keepclassmembers class * { + void *(**On*Event); + void *(**On*Listener); +} + +# webView处理,项目中没有使用到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); +} + + +########################################################################默认配置 + +# 不混淆第三方jar包中的类 +-keep public class * extends android.support.v4.** {*;} +-keep class com.alipay.** {*;} +-keep class com.ta.** {*;} +-keep class com.ut.** {*;} +-keep class com.baidu.** {*;} +-keep class com.alibaba.fastjson.** {*;} +-keep class com.umeng.** {*;} +-keep class org.apache.poi.** {*;} +-keep class com.iflytek.** {*;} +-keep class * extends java.lang.annotation.Annotation { *; } +-keep class android.net.http.SslError +-keep class android.webkit.**{*;} +-keep class cn.sharesdk.**{*;} +-keep class com.sina.**{*;} +-keep class m.framework.**{*;} +-keep public class com.idea.fifaalarmclock.app.R$*{ + public static final int *; +} +-dontwarn org.apache.commons.** +-dontwarn com.iflytek.** +-keepattributes Signature + +#Umeng相关 +-keep class com.umeng.** {*;} +-dontwarn com.umeng.** +-keep public class * extends com.umeng.** +-keep public class com.umeng.fb.ui.ThreadView { +} +-keepclassmembers class * { + public (org.json.JSONObject); +} +-keepclassmembers enum * { + public static **[] values(); + public static ** valueOf(java.lang.String); +} +#Umeng在线参数 +-keep class com.umeng.onlineconfig.OnlineConfigAgent { + public ; + public ; +} +-keep class com.umeng.onlineconfig.OnlineConfigLog { + public ; + public ; +} +-keep interface com.umeng.onlineconfig.UmengOnlineConfigureListener { + public ; +} + +#EventBus +-keepclassmembers class ** { + public void onEvent*(**); + void onEvent*(**); +} +# 不混淆butterknife包下所有的类 +-keep class butterknife.** { *; } +-dontwarn butterknife.internal.** +-keep class **$$ViewBinder { *; } +-keepclasseswithmembernames class * { + @butterknife.* ; +} +-keepclasseswithmembernames class * { + @butterknife.* ; +} +# # ------------------------------------------- +# # ######## picasso混淆 ########## +# # ------------------------------------------- +-dontwarn com.squareup.okhttp.** +-keep class com.squareup.** + +# # ------------------------------------------- +# # ######## fastJson混淆 ########## +# # ------------------------------------------- +-dontwarn com.alibaba.fastjson.** +-keep class com.alibaba.fastjson.** { *; } +-keepclassmembers class * { + public ; +} + +## ---------------------------------- +## ########## Gson混淆 ########## +## ---------------------------------- +-keepattributes Signature +-keep class sun.misc.Unsafe { *; } +-keep class com.google.gson.examples.android.model.** { *; } + +## ---------------------------------- +## ########## retrofit混淆 ########## +## ---------------------------------- +-dontwarn retrofit.** +-keep class retrofit.** { *; } +-keepattributes Signature +-keepattributes Exceptions + +## ---------------------------------- +## ########## ActiveAndroid ########## +## ---------------------------------- +-keep class com.activeandroid.** { *; } +-keep class com.activeandroid.**.** { *; } +-keep class * extends com.activeandroid.Model +-keep class * extends com.activeandroid.serializer.TypeSerializer + +## ---------------------------------- +## ########## 极光推送相关 ########## +## ---------------------------------- +-dontoptimize +-dontpreverify + +-dontwarn cn.jpush.** +-keep class cn.jpush.** { *; } + +-dontwarn cn.jiguang.** +-keep class cn.jiguang.** { *; } + +## ---------------------------------- +## ########## 微信混淆 ########## +## ---------------------------------- +-dontwarn com.tencent.mm.** +-keep class com.tencent.mm.** { *;} +-keep class com.zhiketong.zkthotel.wxapi.** { *; } + +## ---------------------------------- +## ########## LeakCanary ########## +## ---------------------------------- +-keep class org.eclipse.mat.** { *; } +-keep class com.squareup.leakcanary.** { *; } + +## ---------------------------------- +## ########## AndFix ########## +## ---------------------------------- +-printmapping mapping.txt +#-applymapping /Users/maning/Desktop/mapping.txt +-keep class * extends java.lang.annotation.Annotation +-keep class com.alipay.euler.andfix.** { *; } + +## ---------------------------------- +## ########## okhttp ########## +## ---------------------------------- +-dontwarn okhttp3.** +-keep class okhttp3.**{*;} +-keep interface okhttp3.**{*;} +#okio +-dontwarn okio.** +-keep class okio.**{*;} +-keep interface okio.**{*;} + +## ---------------------------------- +## ########## Glide ########## +## ---------------------------------- +-keep public class * implements com.bumptech.glide.module.GlideModule +-keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** { + **[] $VALUES; + public *; +} + +## ---------------------------------- +## ########## APP ########## +## ---------------------------------- +-keep class com.maning.gankmm.bean.** {*;} +-keep class com.maning.gankmm.utils.ACache { *; } + +## ---------------------------------- +## ########## Jsoup ########## +## ---------------------------------- +-keep class org.jsoup.** {*;} + +## ---------------------------------- +## ########## 阿里反馈 ########## +## ---------------------------------- +-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 com.alibaba.sdk.android.feedback.** {*;} + +## ---------------------------------- +## ########## 有米 ########## +## ---------------------------------- +-keep public class android.support.**{ + *; +} + +## ---------------------------------- +## ########## 高德地图 ########## +## ---------------------------------- +-keep class com.amap.api.location.**{*;} +-keep class com.amap.api.fence.**{*;} +-keep class com.autonavi.aps.amapapi.model.**{*;} + +#PictureSelector 2.0 +-keep class com.luck.picture.lib.** { *; } + +-dontwarn com.yalantis.ucrop** +-keep class com.yalantis.ucrop** { *; } +-keep interface com.yalantis.ucrop** { *; } + + #rxjava +-dontwarn sun.misc.** +-keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* { + long producerIndex; + long consumerIndex; +} +-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef { + rx.internal.util.atomic.LinkedQueueNode producerNode; +} +-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueConsumerNodeRef { + rx.internal.util.atomic.LinkedQueueNode consumerNode; +} + +#rxandroid +-dontwarn sun.misc.** +-keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* { + long producerIndex; + long consumerIndex; +} +-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef { + rx.internal.util.atomic.LinkedQueueNode producerNode; +} +-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueConsumerNodeRef { + rx.internal.util.atomic.LinkedQueueNode consumerNode; +} + +#glide +-keep public class * implements com.bumptech.glide.module.GlideModule +-keep public class * extends com.bumptech.glide.AppGlideModule +-keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** { + **[] $VALUES; + public *; +} + +