diff --git a/README.md b/README.md index 6e071fb..32ec3ad 100644 --- a/README.md +++ b/README.md @@ -113,7 +113,7 @@ # 导入指南 ``` groovy -def quicklib = "4.1.1" +def quicklib = "4.2.0" // quicklib(Base) implementation "com.sdwfqin.quicklib:quicklib:$quicklib" @@ -137,7 +137,7 @@ implementation "com.sdwfqin.quicklib:widget:$quicklib" # 混淆 -可参考[Sample混淆文件](/app/proguard-rules.pro) +4.2.0开始支持自动传递混淆配置,如有问题请提Issues或单独添加需要添加的策略~ # 其他 diff --git a/app/build.gradle b/app/build.gradle index 81274f8..63bbc54 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -34,7 +34,9 @@ android { buildTypes { release { // 开启混淆 - minifyEnabled false + minifyEnabled true + shrinkResources true + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' signingConfig signingConfigs.sdwfqinSigning } diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index a40080d..0310149 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -36,34 +36,12 @@ # 这个过滤器是谷歌推荐的算法,一般不做更改 -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.** - # 保留R下面的资源 -keep class **.R$* {*;} @@ -91,158 +69,4 @@ 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); -} - -############################################# -# -# 第三方开源库混淆配置 -# -############################################# - --dontwarn android.arch.** --keep class android.arch.** { *; } --dontwarn com.alibaba.android.vlayout.** --keep class com.alibaba.android.vlayout.** { *; } --dontwarn android.support.** --keep class android.support.** { *; } --dontwarn androidx.constraintlayout.solver.widgets.** --keep class androidx.constraintlayout.solver.widgets.** { *; } --dontwarn com.blankj.utilcode.** --keep class com.blankj.utilcode.** { *; } --dontwarn com.bigkoo.pickerview.** --keep class com.bigkoo.pickerview.** { *; } --dontwarn com.contrarywind.** --keep class com.contrarywind.** { *; } --dontwarn com.bumptech.glide.** --keep class com.bumptech.glide.** { *; } --dontwarn com.github.chrisbanes.photoview.** --keep class com.github.chrisbanes.photoview.** { *; } --dontwarn com.chad.library.** --keep class com.chad.library.** { *; } --dontwarn com.luck.picture.lib.** --keep class com.luck.picture.lib.** { *; } --dontwarn com.yalantis.ucrop.** --keep class com.yalantis.ucrop.** { *; } --dontwarn com.mcxtzhang.swipemenulib.** --keep class com.mcxtzhang.swipemenulib.** { *; } --dontwarn com.google.gson.** --keep class com.google.gson.** { *; } --dontwarn com.google.zxing.** --keep class com.google.zxing.** { *; } --dontwarn com.just.agentweb.** --keep class com.just.agentweb.** { *; } --dontwarn com.otaliastudios.cameraview.** --keep class com.otaliastudios.cameraview.** { *; } --dontwarn com.qmuiteam.qmui.** --keep class com.qmuiteam.qmui.** { *; } --dontwarn com.scwang.smartrefresh.layout.** --keep class com.scwang.smartrefresh.layout.** { *; } --dontwarn me.imid.swipebacklayout.lib.** --keep class me.imid.swipebacklayout.lib.** { *; } --dontwarn org.reactivestreams.** --keep class org.reactivestreams.** { *; } --dontwarn com.tencent.** --keep class dagger.** { *; } --dontwarn dagger.** --keep class com.tencent.** { *; } --dontwarn com.alipay.** --keep class com.alipay.** { *; } --keep class com.sdwfqin.widget.** { *; } --keep class com.sdwfqin.quicklib.** { *; } --keep class com.sdwfqin.qrscan.** { *; } --keep class com.sdwfqin.paylib.** { *; } --keep class com.sdwfqin.imageloader.** { *; } - -#============================Retrofit=========================== -# Retrofit does reflection on generic parameters and InnerClass is required to use Signature. --keepattributes Signature, InnerClasses -# Retain service method parameters when optimizing. --keepclassmembers,allowshrinking,allowobfuscation interface * { - @retrofit2.http.* ; -} -# Ignore annotation used for build tooling. --dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement -# Ignore JSR 305 annotations for embedding nullability information. --dontwarn javax.annotation.** -# Guarded by a NoClassDefFoundError try/catch and only used when on the classpath. --dontwarn kotlin.Unit - -#============================EventBus=========================== --keepattributes *Annotation* --keepclassmembers class * { - @org.greenrobot.eventbus.Subscribe ; -} --keep enum org.greenrobot.eventbus.ThreadMode { *; } -# Only required if you use AsyncExecutor --keepclassmembers class * extends org.greenrobot.eventbus.util.ThrowableFailureEvent { - (java.lang.Throwable); -} -#============================butterknife=========================== --keep public class * implements butterknife.Unbinder { public (**, android.view.View); } --keep class butterknife.* --keepclasseswithmembernames class * { @butterknife.* ; } --keepclasseswithmembernames class * { @butterknife.* ; } -#============================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; -} --dontwarn io.reactivex.** --keep class io.reactivex.**{*;} -#============================OkHttp=========================== -# JSR 305 annotations are for embedding nullability information. --dontwarn javax.annotation.** -# A resource is loaded with a relative path so the package of this class must be preserved. --keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase -# Animal Sniffer compileOnly dependency to ensure APIs are compatible with older versions of Java. --dontwarn org.codehaus.mojo.animal_sniffer.* -# OkHttp platform used only on JVM and when Conscrypt dependency is available. --dontwarn okhttp3.internal.platform.ConscryptPlatform --dontwarn okhttp3.** --keep class okhttp3.**{*;} -#============================OkIo=========================== --dontwarn okio.** --keep class okio.**{*;} \ No newline at end of file +} \ No newline at end of file diff --git a/app/src/main/java/com/sdwfqin/quickseed/ui/mvvm/WeatherBean.java b/app/src/main/java/com/sdwfqin/quickseed/ui/mvvm/WeatherBean.java index 900be7e..da26a52 100644 --- a/app/src/main/java/com/sdwfqin/quickseed/ui/mvvm/WeatherBean.java +++ b/app/src/main/java/com/sdwfqin/quickseed/ui/mvvm/WeatherBean.java @@ -1,5 +1,7 @@ package com.sdwfqin.quickseed.ui.mvvm; +import java.io.Serializable; + /** * 天气bean *

@@ -7,7 +9,7 @@ * @author 张钦 * @date 2020/4/14 */ -public class WeatherBean { +public class WeatherBean implements Serializable { private Integer errcode; private String errmsg; diff --git a/config.gradle b/config.gradle index b39a713..22ba9f2 100644 --- a/config.gradle +++ b/config.gradle @@ -1,7 +1,7 @@ ext { - versionCode = 202007171 - versionName = "4.1.1" + versionCode = 202007201 + versionName = "4.2.0" qmui = "2.0.0-alpha10" okhttp = "4.7.2" diff --git a/imageloader/build.gradle b/imageloader/build.gradle index 1007af0..3072daa 100644 --- a/imageloader/build.gradle +++ b/imageloader/build.gradle @@ -15,8 +15,7 @@ android { buildTypes { release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + consumerProguardFiles 'proguard-rules.pro' } } diff --git a/imageloader/proguard-rules.pro b/imageloader/proguard-rules.pro index f1b4245..507d946 100644 --- a/imageloader/proguard-rules.pro +++ b/imageloader/proguard-rules.pro @@ -19,3 +19,19 @@ # If you keep the line number information, uncomment this to # hide the original source file name. #-renamesourcefileattribute SourceFile + +#glide +-keep public class * implements com.bumptech.glide.module.GlideModule +-keep class * extends com.bumptech.glide.module.AppGlideModule { + (...); +} +-keep public enum com.bumptech.glide.load.ImageHeaderParser$** { + **[] $VALUES; + public *; +} +-keep class com.bumptech.glide.load.data.ParcelFileDescriptorRewinder$InternalRewinder { + *** rewind(); +} +-keep public class * extends androidx.** + +-dontwarn jp.co.cyberagent.android.gpuimage.** diff --git a/paylib/build.gradle b/paylib/build.gradle index ddd3238..0170756 100644 --- a/paylib/build.gradle +++ b/paylib/build.gradle @@ -15,8 +15,7 @@ android { buildTypes { release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + consumerProguardFiles 'proguard-rules.pro' } } diff --git a/paylib/proguard-rules.pro b/paylib/proguard-rules.pro index f1b4245..81e85c1 100644 --- a/paylib/proguard-rules.pro +++ b/paylib/proguard-rules.pro @@ -19,3 +19,6 @@ # If you keep the line number information, uncomment this to # hide the original source file name. #-renamesourcefileattribute SourceFile + +-dontwarn com.alipay.** +-keep class com.alipay.** { *; } diff --git a/quicklib/build.gradle b/quicklib/build.gradle index 15e712f..e4cbfb6 100644 --- a/quicklib/build.gradle +++ b/quicklib/build.gradle @@ -21,8 +21,7 @@ android { buildTypes { release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + consumerProguardFiles 'proguard-rules.pro' } } diff --git a/quicklib/proguard-rules.pro b/quicklib/proguard-rules.pro index f1b4245..1661cb2 100644 --- a/quicklib/proguard-rules.pro +++ b/quicklib/proguard-rules.pro @@ -19,3 +19,151 @@ # If you keep the line number information, uncomment this to # hide the original source file name. #-renamesourcefileattribute SourceFile + +# 枚举类不能被混淆 +-keepclassmembers enum * { + public static **[] values(); + public static ** valueOf(java.lang.String); +} + +# 保留Parcelable序列化的类不能被混淆 gson需要 +-keep class * implements android.os.Parcelable{ + public static final android.os.Parcelable$Creator *; +} + +# 保留Serializable 序列化的类不被混淆 gson需要 +-keepclassmembers class * implements java.io.Serializable { + static final long serialVersionUID; + private static final java.io.ObjectStreamField[] serialPersistentFields; + !static !transient ; +# ; +# ; + private void writeObject(java.io.ObjectOutputStream); + private void readObject(java.io.ObjectInputStream); + java.lang.Object writeReplace(); + java.lang.Object readResolve(); +} +-keepnames class * implements java.io.Serializable + +#androidx混淆 +-keep class androidx.** {*;} +-keep class com.google.android.** {*;} +-keep public class * extends androidx.** +-keep public class * extends com.google.android.** +-keep interface androidx.** {*;} +-dontwarn com.google.android.** +-dontnote com.google.android.** +-dontwarn androidx.** +-dontnote androidx.** + +# 对于带有回调函数的onXXEvent、**On*Listener的,不能被混淆 +-keepclassmembers class * { + void *(**On*Event); + void *(**On*Listener); +} + +# 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); +} + +#vlayout混淆 +-keepattributes InnerClasses +-keep class com.alibaba.android.vlayout.ExposeLinearLayoutManagerEx { *; } + +#gson混淆配置 +##---------------Begin: proguard configuration for Gson ---------- +# Gson uses generic type information stored in a class file when working with fields. Proguard +# removes such information by default, so configure it to keep all of it. +-keepattributes Signature + +# For using GSON @Expose annotation +-keepattributes *Annotation* + +# Gson specific classes +-dontwarn sun.misc.** +#-keep class com.google.gson.stream.** { *; } + +# Prevent proguard from stripping interface information from TypeAdapter, TypeAdapterFactory, +# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter) +-keep class * extends com.google.gson.TypeAdapter +-keep class * implements com.google.gson.TypeAdapterFactory +-keep class * implements com.google.gson.JsonSerializer +-keep class * implements com.google.gson.JsonDeserializer + +# Prevent R8 from leaving Data object members always null +-keepclassmembers,allowobfuscation class * { + @com.google.gson.annotations.SerializedName ; +} +##---------------End: proguard configuration for Gson ---------- + +#eventbus混淆配置 +-keepattributes *Annotation* +-keepclassmembers class * { + @org.greenrobot.eventbus.Subscribe ; +} +-keep enum org.greenrobot.eventbus.ThreadMode { *; } + +# And if you use AsyncExecutor: +-keepclassmembers class * extends org.greenrobot.eventbus.util.ThrowableFailureEvent { + (java.lang.Throwable); +} + +#retrofit混淆配置 如果使用R8,则自动包含收缩和混淆规则。--start +# Retrofit 对方法和参数注释进行反射. +-keepattributes RuntimeVisibleAnnotations, RuntimeVisibleParameterAnnotations + +# 优化时保留服务方法参数 +-keepclassmembers,allowshrinking,allowobfuscation interface * { + @retrofit2.http.* ; +} + +# Ignore annotation used for build tooling. +-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement + +# Ignore JSR 305 annotations for embedding nullability information. +-dontwarn javax.annotation.** + +# Guarded by a NoClassDefFoundError try/catch and only used when on the classpath. +-dontwarn kotlin.Unit + +# Top-level functions that can only be used by Kotlin. +-dontwarn retrofit2.KotlinExtensions +-dontwarn retrofit2.KotlinExtensions$* + +# With R8 full mode, it sees no subtypes of Retrofit interfaces since they are created with a Proxy +# and replaces all potential values with null. Explicitly keeping the interfaces prevents this. +-if interface * { @retrofit2.http.* ; } +-keep,allowobfuscation interface <1> +#retrofit混淆配置--end + +#bugly +-dontwarn com.tencent.bugly.** +-keep public class com.tencent.bugly.**{*;} +-keep class android.support.**{*;} + +# brvah +-keep public class * extends com.chad.library.adapter.base.viewholder.BaseViewHolder { + (...); +} +-keepclassmembers class $ extends com.chad.library.adapter.base.viewholder.BaseViewHolder { + (...); +} + +# Arouter +-keep public class com.alibaba.android.arouter.routes.**{*;} +-keep public class com.alibaba.android.arouter.facade.**{*;} +-keep class * implements com.alibaba.android.arouter.facade.template.ISyringe{*;} + +# If you use the byType method to obtain Service, add the following rules to protect the interface: +-keep interface * implements com.alibaba.android.arouter.facade.template.IProvider + +# If single-type injection is used, that is, no interface is defined to implement IProvider, the following rules need to be added to protect the implementation +# -keep class * implements com.alibaba.android.arouter.facade.template.IProvider \ No newline at end of file diff --git a/widget/build.gradle b/widget/build.gradle index 7726af3..22556bb 100644 --- a/widget/build.gradle +++ b/widget/build.gradle @@ -14,8 +14,7 @@ android { buildTypes { release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + consumerProguardFiles 'proguard-rules.pro' } } diff --git a/widget/proguard-rules.pro b/widget/proguard-rules.pro index f1b4245..eabcb8b 100644 --- a/widget/proguard-rules.pro +++ b/widget/proguard-rules.pro @@ -19,3 +19,12 @@ # If you keep the line number information, uncomment this to # hide the original source file name. #-renamesourcefileattribute SourceFile + +# 保留我们自定义控件(继承自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); +} diff --git a/widget/src/main/java/com/sdwfqin/widget/pictureupload/PictureUpModel.java b/widget/src/main/java/com/sdwfqin/widget/pictureupload/PictureUpModel.java index 739a1bf..62f225a 100644 --- a/widget/src/main/java/com/sdwfqin/widget/pictureupload/PictureUpModel.java +++ b/widget/src/main/java/com/sdwfqin/widget/pictureupload/PictureUpModel.java @@ -1,12 +1,14 @@ package com.sdwfqin.widget.pictureupload; +import java.io.Serializable; + /** * 描述: * * @author zhangqin * @date 2018/5/31 */ -public class PictureUpModel { +public class PictureUpModel implements Serializable { protected T image;