Skip to content

Commit d310efe

Browse files
authored
Merge pull request #244 from Henry-ZHR/proguard
优化混淆规则
2 parents f335054 + 19fba2c commit d310efe

File tree

2 files changed

+27
-157
lines changed

2 files changed

+27
-157
lines changed

Diff for: app/proguard-rules.pro

+24-154
Original file line numberDiff line numberDiff line change
@@ -1,170 +1,40 @@
1-
# Add project specific ProGuard rules here.
2-
# By default, the flags in this file are appended to flags specified
3-
# in d:\Android\sdk/tools/proguard/proguard-android.txt
4-
# You can edit the include path and order by changing the proguardFiles
5-
# directive in build.gradle.
6-
#
7-
# For more details, see
8-
# http://developer.android.com/guide/developing/tools/proguard.html
9-
10-
# Add any project specific keep options here:
11-
12-
# If your project uses WebView with JS, uncomment the following
13-
# and specify the fully qualified class name to the JavaScript interface
14-
# class:
15-
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16-
# public *;
17-
#}
18-
19-
#指定代码的压缩级别
20-
-optimizationpasses 5
21-
#包明不混合大小写
22-
-dontusemixedcaseclassnames
23-
#优化 不优化输入的类文件
24-
-dontoptimize
25-
#混淆时是否记录日志
26-
-verbose
27-
#混淆时所采用的算法
28-
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
29-
#保持哪些类不被混淆
30-
#保护注解
311
-keepattributes *Annotation*
32-
-keepattributes Signature
33-
-keepattributes EnclosingMethod
34-
#崩溃信息
35-
-keepattributes SourceFile,LineNumberTable
362

37-
#basedata
38-
-keepclasseswithmembers class * implements java.io.Serializable{
39-
<fields>;
40-
<methods>;
41-
}
42-
-keep class **.bean.**{*;}
43-
# 保留Parcelable序列化类不被混淆
44-
-keep class * implements android.os.Parcelable {
45-
public static final android.os.Parcelable$Creator *;
46-
}
47-
-keepclassmembers enum * {
48-
public static **[] values();
49-
public static ** valueOf(java.lang.String);
50-
}
51-
-keepclasseswithmembers class * implements android.os.Parcelable{
3+
-keepclasseswithmembers class * implements java.io.Serializable {
524
<fields>;
535
<methods>;
546
}
55-
-keep class * extends remix.myplayer.ui.adapter.holder.BaseViewHolder{*;}
56-
-keep,allowshrinking,allowoptimization,allowobfuscation class remix.myplayer.ui.adapter.BaseAdapter
57-
-keep,allowshrinking,allowoptimization,allowobfuscation class * extends remix.myplayer.ui.adapter.BaseAdapter
587

59-
-keep class **.R$* {*;}
60-
-keep public class remix.myplayer.R$*{
61-
public static final int *;
62-
}
8+
-keep class remix.myplayer.bean.** { *; }
639
-keepclassmembers class ** {
6410
@remix.myplayer.misc.handler.OnHandleMessage public *;
6511
}
6612

67-
-keep public class * extends android.app.Activity
68-
-keep public class * extends android.app.Application
69-
-keep public class * extends android.app.Service
70-
-keep public class * extends android.content.BroadcastReceiver
71-
-keep public class * extends android.content.ContentProvider
72-
-keep public class * extends android.app.backup.BackupAgentHelper
73-
-keep public class * extends android.preference.Preference
74-
-keep public class com.android.vending.licensing.ILicensingService
75-
-keep public class * extends java.lang.annotation.Annotation
76-
-keep public class * extends android.os.Handler
77-
-keep class !android.support.v7.internal.view.menu.**,android.support.** {*;}
78-
79-
-keep public class **.R$*{
80-
public static final int *;
81-
}
82-
83-
# Keep native methods
84-
-keepclassmembers class * {
85-
native <methods>;
86-
}
87-
88-
-dontwarn okio.**
89-
-dontwarn com.squareup.okhttp.**
90-
-dontwarn okhttp3.**
91-
-dontwarn javax.annotation.**
92-
-dontwarn com.android.volley.toolbox.**
93-
-dontwarn com.facebook.infer.**
94-
95-
96-
#retrofit2
97-
-dontwarn retrofit2.**
98-
-keep class retrofit2.** { *; }
99-
-if interface * { @retrofit2.http.* public *** *(...); }
100-
-keep,allowoptimization,allowshrinking,allowobfuscation class <3>
101-
102-
-keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* {
103-
long producerIndex;
104-
long consumerIndex;
105-
}
106-
-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef {
107-
rx.internal.util.atomic.LinkedQueueNode producerNode;
108-
}
109-
-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueConsumerNodeRef {
110-
rx.internal.util.atomic.LinkedQueueNode consumerNode;
111-
}
112-
113-
# FastScrollRecycleView
114-
-keep class com.simplecityapps.recyclerview_fastscroll.** { *; }
115-
116-
#rxpermission
117-
-keep class com.tbruyelle.rxpermissions.**{*;}
118-
119-
#lambda
120-
-dontwarn java.lang.invoke.*
121-
-dontwarn **$$Lambda$*
122-
123-
# 如果你需要兼容6.0系统,请不要混淆org.apache.http.legacy.jar
124-
-dontwarn android.net.compatibility.**
125-
-dontwarn android.net.http.**
126-
-dontwarn com.android.internal.http.multipart.**
127-
-dontwarn org.apache.commons.**
128-
-dontwarn org.apache.http.**
129-
-keep class android.net.compatibility.**{*;}
130-
-keep class android.net.http.**{*;}
131-
-keep class com.android.internal.http.multipart.**{*;}
132-
-keep class org.apache.commons.**{*;}
133-
-keep class org.apache.http.**{*;}
134-
135-
#kotlin
136-
-dontwarn kotlin.**
137-
138-
#bugly
13+
# bugly
14+
# https://bugly.qq.com/docs/user-guide/instruction-manual-android/
15+
-keep public class com.tencent.bugly.** { *; }
13916
-dontwarn com.tencent.bugly.**
140-
-keep public class com.tencent.bugly.**{*;}
141-
142-
#coroutine
143-
-keepnames class kotlinx.coroutines.internal.MainDispatcherFactory {}
144-
-keepnames class kotlinx.coroutines.CoroutineExceptionHandler {}
145-
-keepnames class kotlinx.coroutines.android.AndroidExceptionPreHandler {}
146-
-keepnames class kotlinx.coroutines.android.AndroidDispatcherFactory {}
147-
-keepclassmembernames class kotlinx.** {
148-
volatile <fields>;
149-
}
150-
151-
# kotlinx
152-
-dontwarn kotlinx.**
153-
-keepnames class kotlinx.** { *; }
154-
-keepclassmembernames class kotlinx.** {
155-
volatile <fields>;
156-
}
15717

158-
# logback-android
159-
-keep class ch.qos.** { *; }
160-
-keep class org.slf4j.** { *; }
161-
-keepattributes *Annotation*
162-
-dontwarn ch.qos.logback.core.net.*
18+
# gson
19+
# https://r8.googlesource.com/r8/+/refs/heads/master/compatibility-faq.md
20+
-keep class com.google.gson.reflect.TypeToken { *; }
21+
-keep class * extends com.google.gson.reflect.TypeToken
16322

164-
#jaudiotagger
23+
# jaudiotagger
24+
# Simply keep all classes as they use reflection
16525
-keep class org.jaudiotagger.** { *; }
16626
-dontwarn org.jaudiotagger.**
16727

168-
# Gson
169-
-keep class com.google.gson.reflect.TypeToken { *; }
170-
-keep class * extends com.google.gson.reflect.TypeToken
28+
# logback-android
29+
# https://github.com/tony19/logback-android/issues/229
30+
# They've added consumer-rules.pro, but it seems to be unused
31+
-keepclassmembers class ch.qos.logback.classic.pattern.* { <init>(); }
32+
-keepclassmembers class ch.qos.logback.** { *; }
33+
-keepclassmembers class org.slf4j.impl.** { *; }
34+
-dontwarn ch.qos.logback.core.net.*
35+
# The classes used in app/src/main/assets/logback.xml
36+
# We need these rules to avoid ClassNotFoundException
37+
# Why this isn't mentioned in their document?
38+
-keep class ch.qos.logback.classic.android.LogcatAppender
39+
-keep class ch.qos.logback.core.rolling.RollingFileAppender
40+
-keep class ch.qos.logback.core.rolling.TimeBasedRollingPolicy

Diff for: gradle/libs.versions.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ kotlin = "1.9.23"
44
ksp = "1.9.23-1.0.19"
55

66
glide = "4.16.0"
7-
retrofit = "2.9.0"
7+
retrofit = "2.11.0"
88
room = "2.6.1"
99

1010

@@ -52,15 +52,15 @@ room-rxjava2 = { group = "androidx.room", name = "room-rxjava2", version.ref = "
5252
android-crop = { group = "com.soundcloud.android", name = "android-crop", version = "1.0.1" }
5353
bugly = { group = "com.tencent.bugly", name = "crashreport", version = "3.3.3" }
5454
leakcanary = { group = "com.squareup.leakcanary", name = "leakcanary-android", version = "2.13" }
55-
logback-android = { group = "com.github.tony19", name = "logback-android", version = "2.0.0" }
55+
logback-android = { group = "com.github.tony19", name = "logback-android", version = "3.0.0" }
5656
material-dialog = { group = "com.afollestad.material-dialogs", name = "core", version = "0.9.6.0" }
5757
rebound = { group = "com.facebook.rebound", name = "rebound", version = "0.3.8" }
5858
rxandroid = { group = "io.reactivex.rxjava2", name = "rxandroid", version = "2.1.1" }
5959
rxjava = { group = "io.reactivex.rxjava2", name = "rxjava", version = "2.2.19" }
6060
# noinspection GradleDependency
6161
rxpermissions = { group = "com.github.tbruyelle", name = "rxpermissions", version = "0.11" }
6262
sardine-android = { group = "com.github.thegrizzlylabs", name = "sardine-android", version = "0.9" }
63-
slf4j = { group = "org.slf4j", name = "slf4j-api", version = "2.0.4" }
63+
slf4j = { group = "org.slf4j", name = "slf4j-api", version = "2.0.13" }
6464
timber = { group = "com.jakewharton.timber", name = "timber", version = "5.0.1" }
6565
# noinspection GradleDependency
6666
tinypinyin = { group = "io.github.biezhi", name = "TinyPinyin", version = "2.0.3.RELEASE" }

0 commit comments

Comments
 (0)