proguard-rules.pro 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. # Add project specific ProGuard rules here.
  2. # You can control the set of applied configuration files using the
  3. # proguardFiles setting in build.gradle.
  4. #
  5. # For more details, see
  6. # http://developer.android.com/guide/developing/tools/proguard.html
  7. # If your project uses WebView with JS, uncomment the following
  8. # and specify the fully qualified class name to the JavaScript interface
  9. # class:
  10. #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
  11. # public *;
  12. #}
  13. # Uncomment this to preserve the line number information for
  14. # debugging stack traces.
  15. #-keepattributes SourceFile,LineNumberTable
  16. # 子Module是不需要混淆的,这是因为在主Module中配置了混淆,打包时会作用在所有的Module上,
  17. # 即其他的Module的代码也会被混淆,如果在子Module中再混淆,势必会导致找不到一些类的错误。
  18. # 注意:①所有经由网络JSON转换的实体类,必须实现Serializable且防止混淆!
  19. # 注意:②每新增一个开源库,就要导入相应的混淆规则!
  20. # 关闭代码优化
  21. -dontoptimize
  22. # 处理androidx包
  23. -dontnote androidx.**
  24. -dontwarn androidx.**
  25. # 保留继承的
  26. -keep public class * extends androidx.**
  27. -keep public class * extends android.app.Application
  28. # 保留四大组件,自定义的Application等这些类不被混淆
  29. -keep public class * extends android.app.Activity
  30. -keep public class * extends android.app.Service
  31. -keep public class * extends android.content.BroadcastReceiver
  32. -keep public class * extends android.content.ContentProvider
  33. -keep public class * extends android.app.backup.BackupAgentHelper
  34. -keep public class * extends android.preference.Preference
  35. # google推荐算法
  36. -optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*
  37. # 压缩级别
  38. -optimizationpasses 5
  39. # 优化时允许访问并修改有修饰符的类及类的成员
  40. -allowaccessmodification
  41. # 混淆后类型都为小写
  42. -dontusemixedcaseclassnames
  43. # 混淆时记录日志
  44. -verbose
  45. -ignorewarnings
  46. -keep class javax.inject.** { *; }
  47. # 避免混淆Annotation
  48. -keepattributes *Annotation*
  49. # 防止拥有该成员的类和类成员被混淆
  50. -keepclasseswithmembernames class * {
  51. native <methods>;
  52. }
  53. -keepclasseswithmembers class * {
  54. native <methods>;
  55. }
  56. -keepclassmembers class * {
  57. native <methods>;
  58. }
  59. # 不混淆自定义View
  60. -keepclassmembers public class * extends android.view.View {
  61. void set*(***);
  62. *** get*();
  63. }
  64. -keepclasseswithmembers class * {
  65. public <init>(android.content.Context, android.util.AttributeSet);
  66. }
  67. # 不混淆Activity里的方法,这样就可以在xml的onClick里使用该方法了
  68. #-keepclassmembers class * extends android.app.Activity {
  69. # public void *(android.view.View);
  70. #}
  71. # 不混淆枚举
  72. -keepclassmembers enum * {
  73. public static **[] values();
  74. public static ** valueOf(java.lang.String);
  75. }
  76. # 不混淆Parcelable子类
  77. -keepclassmembers class * implements android.os.Parcelable {
  78. public static final android.os.Parcelable$Creator CREATOR;
  79. }
  80. # 保留R下面的资源
  81. -keepclassmembers class **.R$* {
  82. public static <fields>;
  83. }
  84. -keep class **.R$* {*;}
  85. # The support library contains references to newer platform versions.
  86. # Don't warn about those in case this app is linking against an older
  87. # platform version. We know about them, and they are safe.
  88. -dontwarn android.support.**
  89. # 不混淆Keep注解标记的类
  90. -keep class androidx.annotation.Keep
  91. -keep @androidx.annotation.Keep class * {*;}
  92. -keepclasseswithmembers class * {
  93. @androidx.annotation.Keep <methods>;
  94. }
  95. -keepclasseswithmembers class * {
  96. @androidx.annotation.Keep <fields>;
  97. }
  98. -keepclasseswithmembers class * {
  99. @androidx.annotation.Keep <init>(...);
  100. }
  101. # 将源码中有意义的类名转换成SourceFile,用于混淆具体崩溃代码
  102. #-renamesourcefileattribute SourceFile
  103. # 抛出异常时保留代码行号
  104. #-renamesourcefileattribute flooSDK
  105. #-keepattributes SourceFile,LineNumberTable
  106. #-keepattributes Exceptions,InnerClasses,Signature,EnclosingMethod
  107. # 图片选择 PictureSelector 2.0
  108. -keep class com.luck.picture.lib.** { *; }
  109. # 城市选择
  110. -keep class com.lljjcoder.**{
  111. *;
  112. }
  113. -dontwarn demo.**
  114. -keep class demo.**{*;}
  115. -dontwarn net.sourceforge.pinyin4j.**
  116. -keep class net.sourceforge.pinyin4j.**{*;}
  117. -keep class net.sourceforge.pinyin4j.format.**{*;}
  118. -keep class net.sourceforge.pinyin4j.format.exception.**{*;}
  119. # RxJava RxAndroid
  120. -dontwarn sun.misc.**
  121. -keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* {
  122. long producerIndex;
  123. long consumerIndex;
  124. }
  125. -dontwarn com.tbruyelle.rxpermissions.**
  126. # Android源码
  127. -keep class com.google.android.material.** { *; }
  128. -dontwarn com.google.android.material.**
  129. -dontnote com.google.android.material.**
  130. -keep class com.google.** { *; }
  131. -dontwarn androidx.**
  132. -keep interface androidx.** { *; }
  133. -keep class androidx.** {*;}
  134. -keep class com.google.** { *; }
  135. -keep interface com.google.** { *; }
  136. -dontwarn com.google.**
  137. -keep class com.google.protobuf.* {*;}
  138. -dontwarn com.google.protobuf.**
  139. # 一些开源项目
  140. -keep class com.github.** { *; }
  141. -keep class com.wangjie.** { *; }
  142. -keep class com.bigkoo.** { *; }
  143. -keep class com.blankj.** { *; }
  144. -keep class com.miekir.** { *; }
  145. # okhttp
  146. # A resource is loaded with a relative path so the package of this class must be preserved.
  147. -keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase
  148. # Animal Sniffer compileOnly dependency to ensure APIs are compatible with older versions of Java.
  149. -dontwarn org.codehaus.mojo.animal_sniffer.*
  150. # OkHttp platform used only on JVM and when Conscrypt dependency is available.
  151. -dontwarn okhttp3.internal.platform.ConscryptPlatform
  152. -dontwarn org.conscrypt.ConscryptHostnameVerifier
  153. -dontwarn okio.**
  154. -keep class com.squareup.okhttp.** { *;}
  155. -dontwarn com.squareup.okhttp.**
  156. -dontwarn javax.annotation.**
  157. -keep class okhttp3.** { *; }
  158. -keep interface okhttp3.** { *; }
  159. -dontwarn okhttp3.**
  160. # Retrofit
  161. -keep class retrofit2.** { *; }
  162. -keep interface retrofit2.** { *; }
  163. -dontwarn retrofit2.**
  164. -keepattributes Signature, InnerClasses, EnclosingMethod
  165. # Retrofit does reflection on method and parameter annotations.
  166. -keepattributes RuntimeVisibleAnnotations, RuntimeVisibleParameterAnnotations
  167. # Keep annotation default values (e.g., retrofit2.http.Field.encoded).
  168. -keepattributes AnnotationDefault
  169. # Retain service method parameters when optimizing.
  170. -keepclassmembers,allowshrinking,allowobfuscation interface * {
  171. @retrofit2.http.* <methods>;
  172. }
  173. # Ignore annotation used for build tooling.
  174. -dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
  175. # Ignore JSR 305 annotations for embedding nullability information.
  176. -dontwarn javax.annotation.**
  177. # Guarded by a NoClassDefFoundError try/catch and only used when on the classpath.
  178. -dontwarn kotlin.Unit
  179. # Top-level functions that can only be used by Kotlin.
  180. -dontwarn retrofit2.KotlinExtensions
  181. -dontwarn retrofit2.KotlinExtensions$*
  182. # With R8 full mode, it sees no subtypes of Retrofit interfaces since they are created with a Proxy
  183. # and replaces all potential values with null. Explicitly keeping the interfaces prevents this.
  184. -if interface * { @retrofit2.http.* <methods>; }
  185. -keep,allowobfuscation interface <1>
  186. # Keep generic signature of Call, Response (R8 full mode strips signatures from non-kept items).
  187. -keep,allowobfuscation,allowshrinking interface retrofit2.Call
  188. -keep,allowobfuscation,allowshrinking class retrofit2.Response
  189. # With R8 full mode generic signatures are stripped for classes that are not
  190. # kept. Suspend functions are wrapped in continuations where the type argument
  191. # is used.
  192. -keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation
  193. # LeakCanary
  194. -dontwarn com.squareup.haha.guava.**
  195. -dontwarn com.squareup.haha.perflib.**
  196. -dontwarn com.squareup.haha.trove.**
  197. -dontwarn com.squareup.leakcanary.**
  198. -keep class com.squareup.** { *; }
  199. -keep class leakcanary.** { *; }
  200. # Marshmallow removed Notification.setLatestEventInfo()
  201. -dontwarn android.app.Notification
  202. # Glide
  203. -keep public class * implements com.bumptech.glide.module.GlideModule
  204. -keep class * extends com.bumptech.glide.module.AppGlideModule {
  205. <init>(...);
  206. }
  207. -keep public enum com.bumptech.glide.load.ImageHeaderParser$** {
  208. **[] $VALUES;
  209. public *;
  210. }
  211. -keep class com.bumptech.glide.load.data.ParcelFileDescriptorRewinder$InternalRewinder {
  212. *** rewind();
  213. }
  214. # GSON
  215. -keep class * extends com.google.gson.TypeAdapter
  216. -keep class * implements com.google.gson.TypeAdapterFactory
  217. -keep class * implements com.google.gson.JsonSerializer
  218. -keep class * implements com.google.gson.JsonDeserializer
  219. -keep class org.json.* {*;}
  220. # BaseQuickAdapter
  221. -keep class com.chad.library.adapter.** {
  222. *;
  223. }
  224. -keep public class * extends com.chad.library.adapter.base.BaseQuickAdapter
  225. # AutoSize
  226. -keep class com.miekir.common.autosize.** { *; }
  227. -keep interface com.miekir.common.autosize.** { *; }
  228. #kotlin
  229. -dontwarn org.jetbrains.**
  230. -dontwarn com.ted.floo.**
  231. -keep class org.jetbrains.** { *; }
  232. -keep interface org.jetbrains.** { *; }
  233. -keep class kotlin.** { *; }
  234. -keep interface kotlin.** { *; }
  235. -keepclassmembers class kotlin.Metadata {
  236. public <methods>;
  237. }
  238. -keepclassmembers class **.WhenMappings {
  239. <fields>;
  240. }
  241. -assumenosideeffects class kotlin.jvm.internal.Intrinsics {
  242. static void checkParameterIsNotNull(java.lang.Object, java.lang.String);
  243. }
  244. -dontwarn kotlin.**
  245. -keep class kotlinx.** { *; }
  246. -keep interface kotlinx.** { *; }
  247. -dontwarn kotlinx.**
  248. # lateinit变量
  249. -keepclasseswithmembers @kotlin.Metadata class * { *; }
  250. -keep @kotlin.Metadata class *
  251. # 饺子播放器
  252. -keep public class cn.jzvd.JZMediaSystem {*; }
  253. # ijk播放器
  254. -keep class tv.danmaku.ijk.media.player.** {*; }
  255. -dontwarn tv.danmaku.ijk.media.player.*
  256. -keep interface tv.danmaku.ijk.media.player.** { *; }
  257. -dontwarn com.tencent.bugly.**
  258. -keep public class com.tencent.bugly.**{*;}
  259. # 高德地图
  260. # 定位
  261. -keep class com.amap.api.location.**{*;}
  262. -keep class com.amap.api.fence.**{*;}
  263. -keep class com.loc.**{*;}
  264. -keep class com.autonavi.aps.amapapi.model.**{*;}
  265. -dontwarn com.amap.api.**
  266. -dontwarn com.autonavi.**
  267. -keep class com.amap.api.** {*;}
  268. -keep class com.autonavi.** {*;}
  269. # 搜索
  270. -keep class com.amap.api.services.**{*;}
  271. # 2D地图
  272. -keep class com.amap.api.maps2d.**{*;}
  273. -keep class com.amap.api.mapcore2d.**{*;}