Skip to content
This repository was archived by the owner on Jul 16, 2024. It is now read-only.

Commit 26c5f26

Browse files
authored
Cleanup proguard rules (#10)
* Update proguard-rules.pro Copied from https://github.com/Goooler/CatchUp/blob/25ee15fc5ffaa432f6a10677eebee470800bb178/app/proguard-rules.pro * Add Arouter rules * Add mapping,seeds,unused rules * Remove unused * Just keep inflate method in ViewDataBinding's subclasses * Indent
1 parent 80f35c2 commit 26c5f26

File tree

1 file changed

+57
-70
lines changed

1 file changed

+57
-70
lines changed

gradle/proguard-rules.pro

Lines changed: 57 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,77 @@
1-
-verbose
1+
# This is a configuration file for ProGuard.
2+
# http://proguard.sourceforge.net/index.html#manual/usage.html
23
-allowaccessmodification
4+
-dontpreverify
35
-dontusemixedcaseclassnames
46
-dontskipnonpubliclibraryclasses
5-
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
6-
-dump class_files.txt
7+
-verbose
78
-printseeds seeds.txt
89
-printusage unused.txt
910
-printmapping mapping.txt
10-
-keepattributes *Annotation*,SourceFile,LineNumberTable,Signature
11-
-renamesourcefileattribute SourceFile
12-
-dontwarn java.util.concurrent.Flow*
13-
-keep class **.R$* {*;}
11+
12+
# For native methods, see http://proguard.sourceforge.net/manual/examples.html#native
1413
-keepclasseswithmembernames class * {
15-
native <methods>;
14+
native <methods>;
1615
}
16+
17+
# For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations
1718
-keepclassmembers enum * {
18-
public static **[] values();
19-
public static ** valueOf(java.lang.String);
19+
public static **[] values();
20+
public static ** valueOf(java.lang.String);
2021
}
21-
-keepclassmembers class * {
22-
void *(**On*Event);
23-
void *(**On*Listener);
22+
23+
-keepclassmembers class * implements android.os.Parcelable {
24+
public static final android.os.Parcelable$Creator CREATOR;
2425
}
2526

27+
# Assume isInEditMode() always return false in release builds so they can be pruned
28+
-assumevalues public class * extends android.view.View {
29+
boolean isInEditMode() return false;
30+
}
2631

27-
# Serializable
28-
-keep class * implements android.os.Parcelable {
29-
public static final android.os.Parcelable$Creator *;
32+
-keepclassmembers class **.R$* {
33+
public static <fields>;
3034
}
31-
-keepclassmembers class * implements java.io.Serializable {
32-
static final long serialVersionUID;
33-
private static final java.io.ObjectStreamField[] serialPersistentFields;
34-
!static !transient <fields>;
35-
!private <fields>;
36-
!private <methods>;
37-
private void writeObject(java.io.ObjectOutputStream);
38-
private void readObject(java.io.ObjectInputStream);
39-
java.lang.Object writeReplace();
40-
java.lang.Object readResolve();
35+
36+
-keepattributes Signature,InnerClasses,EnclosingMethod,*Annotation*
37+
38+
# Retrofit
39+
# This is to keep parameters on retrofit2.http-annotated methods while still allowing removal of unused ones
40+
-keep,allowobfuscation @interface retrofit2.http.**
41+
-keepclassmembers,allowshrinking,allowobfuscation interface * {
42+
@retrofit2.http.** <methods>;
4143
}
4244

45+
# Okio
46+
-dontwarn okio.**
4347

44-
# DataBinding
45-
-keep public class * extends androidx.databinding.ViewDataBinding {*;}
48+
# Kotlin
49+
-dontwarn kotlin.**
4650

51+
# Some unsafe classfactory stuff
52+
-keep class sun.misc.Unsafe { *; }
53+
54+
# Ensure the custom, fast service loader implementation is removed. R8 will fold these for us
55+
-assumenosideeffects class kotlinx.coroutines.internal.MainDispatcherLoader {
56+
boolean FAST_SERVICE_LOADER_ENABLED return false;
57+
}
58+
-assumenosideeffects class kotlinx.coroutines.internal.FastServiceLoader {
59+
boolean ANDROID_DETECTED return true;
60+
}
61+
-checkdiscard class kotlinx.coroutines.internal.FastServiceLoader
4762

48-
# WebView
49-
-keepclassmembers class * extends android.webkit.WebViewClient {*;}
50-
-keepclassmembers class * extends android.webkit.WebChromeClient.WebChromeClient {*;}
63+
# Check that qualifier annotations have been discarded.
64+
-checkdiscard @javax.inject.Qualifier class *
5165

66+
# Coroutines debug agent bits
67+
-dontwarn java.lang.instrument.ClassFileTransformer
68+
-dontwarn sun.misc.SignalHandler
69+
70+
# From OkHttp but gated appropriately
71+
-dontwarn org.conscrypt.ConscryptHostnameVerifier
72+
73+
# ZoneRulesProvider _does_ exist!
74+
-dontwarn java.time.zone.ZoneRulesProvider
5275

5376
# Arouter
5477
-keep public class com.alibaba.android.arouter.routes.**{*;}
@@ -57,43 +80,7 @@
5780
-keep interface * implements com.alibaba.android.arouter.facade.template.IProvider
5881
-keep class * implements com.alibaba.android.arouter.facade.template.IProvider
5982

60-
61-
# Glide
62-
-keep public class * implements com.bumptech.glide.module.GlideModule
63-
-keep class * extends com.bumptech.glide.module.AppGlideModule {
64-
<init>(...);
65-
}
66-
-keep public enum com.bumptech.glide.load.ImageHeaderParser$** {
67-
**[] $VALUES;
68-
public *;
69-
}
70-
-keep class com.bumptech.glide.load.data.ParcelFileDescriptorRewinder$InternalRewinder {
71-
*** rewind();
72-
}
73-
74-
75-
# Gson
76-
-dontwarn sun.misc.**
77-
-keep class com.google.gson.stream.** { *; }
78-
-keep class com.google.gson.examples.android.model.** { <fields>; }
79-
-keep class * extends com.google.gson.TypeAdapter
80-
-keep class * implements com.google.gson.TypeAdapterFactory
81-
-keep class * implements com.google.gson.JsonSerializer
82-
-keep class * implements com.google.gson.JsonDeserializer
83-
-keepclassmembers,allowobfuscation class * {
84-
@com.google.gson.annotations.SerializedName <fields>;
83+
# DataBinding
84+
-keep public class * extends androidx.databinding.ViewDataBinding {
85+
* inflate(android.view.LayoutInflater);
8586
}
86-
87-
88-
# Amap
89-
-keep class com.amap.api.maps.**{*;}
90-
-keep class com.autonavi.**{*;}
91-
-keep class com.amap.api.trace.**{*;}
92-
-keep class com.amap.api.location.**{*;}
93-
-keep class com.amap.api.fence.**{*;}
94-
-keep class com.autonavi.aps.amapapi.model.**{*;}
95-
-keep class com.amap.api.services.**{*;}
96-
-keep class com.amap.api.maps2d.**{*;}
97-
-keep class com.amap.api.mapcore2d.**{*;}
98-
-keep class com.amap.api.navi.**{*;}
99-
-keep class com.autonavi.**{*;}

0 commit comments

Comments
 (0)