Skip to content

Commit 09aa4c6

Browse files
committed
添加自动混淆
1 parent ed1f09a commit 09aa4c6

File tree

14 files changed

+194
-192
lines changed

14 files changed

+194
-192
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
# 导入指南
114114
115115
``` groovy
116-
def quicklib = "4.1.1"
116+
def quicklib = "4.2.0"
117117
118118
// quicklib(Base)
119119
implementation "com.sdwfqin.quicklib:quicklib:$quicklib"
@@ -137,7 +137,7 @@ implementation "com.sdwfqin.quicklib:widget:$quicklib"
137137

138138
# 混淆
139139

140-
可参考[Sample混淆文件](/app/proguard-rules.pro)
140+
4.2.0开始支持自动传递混淆配置,如有问题请提Issues或单独添加需要添加的策略~
141141

142142
# 其他
143143

app/build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ android {
3434
buildTypes {
3535
release {
3636
// 开启混淆
37-
minifyEnabled false
37+
minifyEnabled true
38+
shrinkResources true
39+
3840
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
3941
signingConfig signingConfigs.sdwfqinSigning
4042
}

app/proguard-rules.pro

Lines changed: 1 addition & 177 deletions
Original file line numberDiff line numberDiff line change
@@ -36,34 +36,12 @@
3636
# 这个过滤器是谷歌推荐的算法,一般不做更改
3737
-optimizations !code/simplification/cast,!field/*,!class/merging/*
3838

39-
4039
#############################################
4140
#
4241
# Android开发中一些需要保留的公共部分
4342
#
4443
#############################################
4544

46-
# 保留我们使用的四大组件,自定义的Application等等这些类不被混淆
47-
# 因为这些子类都有可能被外部调用
48-
-keep public class * extends android.app.Activity
49-
-keep public class * extends android.app.Appliction
50-
-keep public class * extends android.app.Service
51-
-keep public class * extends android.content.BroadcastReceiver
52-
-keep public class * extends android.content.ContentProvider
53-
-keep public class * extends android.app.backup.BackupAgentHelper
54-
-keep public class * extends android.preference.Preference
55-
-keep public class * extends android.view.View
56-
-keep public class com.android.vending.licensing.ILicensingService
57-
58-
59-
# 保留support下的所有类及其内部类
60-
-keep class android.support.** {*;}
61-
62-
# 保留继承的
63-
-keep public class * extends android.support.v4.**
64-
-keep public class * extends android.support.v7.**
65-
-keep public class * extends android.support.annotation.**
66-
6745
# 保留R下面的资源
6846
-keep class **.R$* {*;}
6947

@@ -91,158 +69,4 @@
9169
public <init>(android.content.Context);
9270
public <init>(android.content.Context, android.util.AttributeSet);
9371
public <init>(android.content.Context, android.util.AttributeSet, int);
94-
}
95-
96-
# 保留Parcelable序列化类不被混淆
97-
-keep class * implements android.os.Parcelable {
98-
public static final android.os.Parcelable$Creator *;
99-
}
100-
101-
# 保留Serializable序列化的类不被混淆
102-
-keepclassmembers class * implements java.io.Serializable {
103-
static final long serialVersionUID;
104-
private static final java.io.ObjectStreamField[] serialPersistentFields;
105-
!static !transient <fields>;
106-
!private <fields>;
107-
!private <methods>;
108-
private void writeObject(java.io.ObjectOutputStream);
109-
private void readObject(java.io.ObjectInputStream);
110-
java.lang.Object writeReplace();
111-
java.lang.Object readResolve();
112-
}
113-
114-
# 对于带有回调函数的onXXEvent、**On*Listener的,不能被混淆
115-
-keepclassmembers class * {
116-
void *(**On*Event);
117-
void *(**On*Listener);
118-
}
119-
120-
# webView处理,项目中没有使用到webView忽略即可
121-
-keepclassmembers class fqcn.of.javascript.interface.for.webview {
122-
public *;
123-
}
124-
-keepclassmembers class * extends android.webkit.webViewClient {
125-
public void *(android.webkit.WebView, java.lang.String, android.graphics.Bitmap);
126-
public boolean *(android.webkit.WebView, java.lang.String);
127-
}
128-
-keepclassmembers class * extends android.webkit.webViewClient {
129-
public void *(android.webkit.webView, jav.lang.String);
130-
}
131-
132-
#############################################
133-
#
134-
# 第三方开源库混淆配置
135-
#
136-
#############################################
137-
138-
-dontwarn android.arch.**
139-
-keep class android.arch.** { *; }
140-
-dontwarn com.alibaba.android.vlayout.**
141-
-keep class com.alibaba.android.vlayout.** { *; }
142-
-dontwarn android.support.**
143-
-keep class android.support.** { *; }
144-
-dontwarn androidx.constraintlayout.solver.widgets.**
145-
-keep class androidx.constraintlayout.solver.widgets.** { *; }
146-
-dontwarn com.blankj.utilcode.**
147-
-keep class com.blankj.utilcode.** { *; }
148-
-dontwarn com.bigkoo.pickerview.**
149-
-keep class com.bigkoo.pickerview.** { *; }
150-
-dontwarn com.contrarywind.**
151-
-keep class com.contrarywind.** { *; }
152-
-dontwarn com.bumptech.glide.**
153-
-keep class com.bumptech.glide.** { *; }
154-
-dontwarn com.github.chrisbanes.photoview.**
155-
-keep class com.github.chrisbanes.photoview.** { *; }
156-
-dontwarn com.chad.library.**
157-
-keep class com.chad.library.** { *; }
158-
-dontwarn com.luck.picture.lib.**
159-
-keep class com.luck.picture.lib.** { *; }
160-
-dontwarn com.yalantis.ucrop.**
161-
-keep class com.yalantis.ucrop.** { *; }
162-
-dontwarn com.mcxtzhang.swipemenulib.**
163-
-keep class com.mcxtzhang.swipemenulib.** { *; }
164-
-dontwarn com.google.gson.**
165-
-keep class com.google.gson.** { *; }
166-
-dontwarn com.google.zxing.**
167-
-keep class com.google.zxing.** { *; }
168-
-dontwarn com.just.agentweb.**
169-
-keep class com.just.agentweb.** { *; }
170-
-dontwarn com.otaliastudios.cameraview.**
171-
-keep class com.otaliastudios.cameraview.** { *; }
172-
-dontwarn com.qmuiteam.qmui.**
173-
-keep class com.qmuiteam.qmui.** { *; }
174-
-dontwarn com.scwang.smartrefresh.layout.**
175-
-keep class com.scwang.smartrefresh.layout.** { *; }
176-
-dontwarn me.imid.swipebacklayout.lib.**
177-
-keep class me.imid.swipebacklayout.lib.** { *; }
178-
-dontwarn org.reactivestreams.**
179-
-keep class org.reactivestreams.** { *; }
180-
-dontwarn com.tencent.**
181-
-keep class dagger.** { *; }
182-
-dontwarn dagger.**
183-
-keep class com.tencent.** { *; }
184-
-dontwarn com.alipay.**
185-
-keep class com.alipay.** { *; }
186-
-keep class com.sdwfqin.widget.** { *; }
187-
-keep class com.sdwfqin.quicklib.** { *; }
188-
-keep class com.sdwfqin.qrscan.** { *; }
189-
-keep class com.sdwfqin.paylib.** { *; }
190-
-keep class com.sdwfqin.imageloader.** { *; }
191-
192-
#============================Retrofit===========================
193-
# Retrofit does reflection on generic parameters and InnerClass is required to use Signature.
194-
-keepattributes Signature, InnerClasses
195-
# Retain service method parameters when optimizing.
196-
-keepclassmembers,allowshrinking,allowobfuscation interface * {
197-
@retrofit2.http.* <methods>;
198-
}
199-
# Ignore annotation used for build tooling.
200-
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
201-
# Ignore JSR 305 annotations for embedding nullability information.
202-
-dontwarn javax.annotation.**
203-
# Guarded by a NoClassDefFoundError try/catch and only used when on the classpath.
204-
-dontwarn kotlin.Unit
205-
206-
#============================EventBus===========================
207-
-keepattributes *Annotation*
208-
-keepclassmembers class * {
209-
@org.greenrobot.eventbus.Subscribe <methods>;
210-
}
211-
-keep enum org.greenrobot.eventbus.ThreadMode { *; }
212-
# Only required if you use AsyncExecutor
213-
-keepclassmembers class * extends org.greenrobot.eventbus.util.ThrowableFailureEvent {
214-
<init>(java.lang.Throwable);
215-
}
216-
#============================butterknife===========================
217-
-keep public class * implements butterknife.Unbinder { public <init>(**, android.view.View); }
218-
-keep class butterknife.*
219-
-keepclasseswithmembernames class * { @butterknife.* <methods>; }
220-
-keepclasseswithmembernames class * { @butterknife.* <fields>; }
221-
#============================RxJava===========================
222-
-dontwarn sun.misc.**
223-
-keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* {
224-
long producerIndex;
225-
long consumerIndex;
226-
}
227-
-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef {
228-
rx.internal.util.atomic.LinkedQueueNode producerNode;
229-
}
230-
-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueConsumerNodeRef {
231-
rx.internal.util.atomic.LinkedQueueNode consumerNode;
232-
}
233-
-dontwarn io.reactivex.**
234-
-keep class io.reactivex.**{*;}
235-
#============================OkHttp===========================
236-
# JSR 305 annotations are for embedding nullability information.
237-
-dontwarn javax.annotation.**
238-
# A resource is loaded with a relative path so the package of this class must be preserved.
239-
-keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase
240-
# Animal Sniffer compileOnly dependency to ensure APIs are compatible with older versions of Java.
241-
-dontwarn org.codehaus.mojo.animal_sniffer.*
242-
# OkHttp platform used only on JVM and when Conscrypt dependency is available.
243-
-dontwarn okhttp3.internal.platform.ConscryptPlatform
244-
-dontwarn okhttp3.**
245-
-keep class okhttp3.**{*;}
246-
#============================OkIo===========================
247-
-dontwarn okio.**
248-
-keep class okio.**{*;}
72+
}

app/src/main/java/com/sdwfqin/quickseed/ui/mvvm/WeatherBean.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
package com.sdwfqin.quickseed.ui.mvvm;
22

3+
import java.io.Serializable;
4+
35
/**
46
* 天气bean
57
* <p>
68
*
79
* @author 张钦
810
* @date 2020/4/14
911
*/
10-
public class WeatherBean {
12+
public class WeatherBean implements Serializable {
1113

1214
private Integer errcode;
1315
private String errmsg;

config.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
ext {
22

3-
versionCode = 202007171
4-
versionName = "4.1.1"
3+
versionCode = 202007201
4+
versionName = "4.2.0"
55

66
qmui = "2.0.0-alpha10"
77
okhttp = "4.7.2"

imageloader/build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ android {
1515

1616
buildTypes {
1717
release {
18-
minifyEnabled false
19-
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18+
consumerProguardFiles 'proguard-rules.pro'
2019
}
2120
}
2221

imageloader/proguard-rules.pro

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,19 @@
1919
# If you keep the line number information, uncomment this to
2020
# hide the original source file name.
2121
#-renamesourcefileattribute SourceFile
22+
23+
#glide
24+
-keep public class * implements com.bumptech.glide.module.GlideModule
25+
-keep class * extends com.bumptech.glide.module.AppGlideModule {
26+
<init>(...);
27+
}
28+
-keep public enum com.bumptech.glide.load.ImageHeaderParser$** {
29+
**[] $VALUES;
30+
public *;
31+
}
32+
-keep class com.bumptech.glide.load.data.ParcelFileDescriptorRewinder$InternalRewinder {
33+
*** rewind();
34+
}
35+
-keep public class * extends androidx.**
36+
37+
-dontwarn jp.co.cyberagent.android.gpuimage.**

paylib/build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ android {
1515

1616
buildTypes {
1717
release {
18-
minifyEnabled false
19-
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18+
consumerProguardFiles 'proguard-rules.pro'
2019
}
2120
}
2221

paylib/proguard-rules.pro

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@
1919
# If you keep the line number information, uncomment this to
2020
# hide the original source file name.
2121
#-renamesourcefileattribute SourceFile
22+
23+
-dontwarn com.alipay.**
24+
-keep class com.alipay.** { *; }

quicklib/build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ android {
2121

2222
buildTypes {
2323
release {
24-
minifyEnabled false
25-
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
24+
consumerProguardFiles 'proguard-rules.pro'
2625
}
2726
}
2827

0 commit comments

Comments
 (0)