-
Notifications
You must be signed in to change notification settings - Fork 62
Expand file tree
/
Copy pathproguard-rules.pro
More file actions
209 lines (172 loc) · 8.03 KB
/
proguard-rules.pro
File metadata and controls
209 lines (172 loc) · 8.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
#https://github.com/ysrc/AndroidObfuseDictionary
#https://github.com/WrBug/FrenziedProguard
# ----------------------------------------------------------------------------
# 混淆的压缩比例,0-7 表示对代码进行迭代优化的次数,optimization可以对代码进行各种优化,每次优化后还可以继续优化,故称之迭代优化
-optimizationpasses 7
# 为了让插件和原来的宿主兼容,需要使用ProGuard的applymapping功能的进行增量混淆,
# 先编译插件release包,然后把插件release编译生成的mapping.txt文件复制到宿主的代码目录下,在宿主的proguard-rules.pro文件中增加配置 -applymapping mapping.txt
-applymapping mapping.txt
# https://blog.csdn.net/wmadao11/article/details/102613078
-allowaccessmodification
# 不做预校验,预校验是作用在Java平台上的,Android平台上不需要这项功能,去掉之后还可以加快混淆速度
-dontpreverify
# 指定不去忽略非公共的库的类的成员
-dontskipnonpubliclibraryclassmembers
# 指定混淆是采用的算法
-optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*
# 指定外部模糊字典 dic.txt 改为混淆文件名,下同
-obfuscationdictionary dic.txt
# 指定class模糊字典
-classobfuscationdictionary dic.txt
# 指定package模糊字典
-packageobfuscationdictionary dic.txt
#-------------------------------common-------------------------------
# 混淆后类型都为小写
-dontusemixedcaseclassnames
# 不跳过非公共的库的类
-dontskipnonpubliclibraryclasses
# 混淆时记录日志
-verbose
# 保留Annotation不混淆,避免混淆泛型;抛出异常时保留代码行号;避免混淆注解、内部类、泛型、匿名类
-keepattributes Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,*Annotation*,EnclosingMethod,LocalVariableTable,*JavascriptInterface*
# 将源码中有意义的类名转换成SourceFile,用于混淆具体崩溃代码
# hide the original source file name.
-renamesourcefileattribute SourceFile
#==============proguard6.2.2/gradle/src/proguard/gradle/proguard-android-common.pro start======
# 保持哪些类不被混淆
# From default AGP configuration.
# Make sure that such classes are kept as they are
# referenced from the AndroidManifest.xml or other
# resource files. Some rules might be obsoleted by
# aapt generated rules but keep them to be sure.
-dontnote android.support.v4.app.Fragment
-dontnote com.google.vending.licensing.ILicensingService
-dontnote com.android.vending.licensing.ILicensingService
-keep public class * extends android.app.Activity
-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.BackupAgent
-keep public class * extends android.preference.Preference
#noinspection ShrinkerUnresolvedReference
-keep public class * extends android.support.v4.app.Fragment
-keep public class * extends android.app.Fragment
-keep public class com.google.vending.licensing.ILicensingService
-keep public class com.android.vending.licensing.ILicensingService
-keep public class * extends java.lang.Throwable {*;}
-keep public class * extends java.lang.Exception {*;}
# From the default AGP config: keep constructors that are called from
# the system via reflection.
-keep public class * extends android.view.View {
public <init>(android.content.Context);
public <init>(android.content.Context, android.util.AttributeSet);
public <init>(android.content.Context, android.util.AttributeSet, int);
public void set*(...);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
# For native methods, see http://proguard.sourceforge.net/manual/examples.html#native
-keepclasseswithmembernames class * {
native <methods>;
}
# 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*();
}
# For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keepclassmembers class * implements android.os.Parcelable {
#noinspection ShrinkerUnresolvedReference
public static final android.os.Parcelable$Creator CREATOR;
}
# 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.**
# Understand the @Keep support annotation.
-dontnote android.support.annotation.Keep
-keep class android.support.annotation.Keep
-keep @android.support.annotation.Keep class * {*;}
-keepclasseswithmembers class * {
#noinspection ShrinkerUnresolvedReference
@android.support.annotation.Keep <methods>;
}
-keepclasseswithmembers class * {
#noinspection ShrinkerUnresolvedReference
@android.support.annotation.Keep <fields>;
}
-keepclasseswithmembers class * {
#noinspection ShrinkerUnresolvedReference
@android.support.annotation.Keep <init>(...);
}
#==============proguard6.2.2/gradle/src/proguard/gradle/proguard-android-common.pro end======
# 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);
}
-keepclassmembers class * implements java.io.Serializable {
static final long serialVersionUID;
private static final java.io.ObjectStreamField[] serialPersistentFields;
private void writeObject(java.io.ObjectOutputStream);
private void readObject(java.io.ObjectInputStream);
java.lang.Object writeReplace();
java.lang.Object readResolve();
}
-keep class **.R
-keepclassmembers class **.R$* {
public static <fields>;
}
#-------------------------------common-------------------------------
##-------------------------------androidx-------------------------------
-keep class androidx.appcompat.view.ContextThemeWrapper {*;}
##-------------------------------androidx-------------------------------
#https://proandroiddev.com/improving-proguard-name-obfuscation-83b27b34c52a
-repackageclasses 'o'
-printconfiguration proguard-merge-config.txt
#-------------------------------reflect system api.-------------------------------
#-keepclassmembers class android.content.pm.ApplicationInfo {
# public java.lang.String scanSourceDir;
# public java.lang.String scanPublicSourceDir;
# public java.lang.String deviceProtectedDataDir;
# public java.lang.String credentialProtectedDataDir;
# #noinspection ShrinkerUnresolvedReference
# public java.lang.String deviceEncryptedDataDir;
# public java.lang.String credentialEncryptedDataDir;
#}
#
#-keepclassmembers class android.os.Handler{
# #noinspection ShrinkerUnresolvedReference
# final android.os.Handler$Callback mCallback;
#}
#-------------------------------reflect system api.-------------------------------
-dontwarn kotlin.**
-keep class kotlinx.** {*;}
-dontwarn kotlinx.**