proguard-rules.pro 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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. # If you keep the line number information, uncomment this to
  17. # hide the original source file name.
  18. #-renamesourcefileattribute SourceFile
  19. # =================================================================
  20. # =========================== 通用設置 ===========================
  21. # =================================================================
  22. #-renamesourcefileattribute SourceFile
  23. -optimizationpasses 7
  24. # 混淆时不使用大小写混合,混淆后的类名为小写
  25. # windows下的同学还是加入这个选项吧(windows大小写不敏感)
  26. -dontusemixedcaseclassnames
  27. # 指定不去忽略非公共的库的类
  28. # 默认跳过,有些情况下编写的代码与类库中的类在同一个包下,并且持有包中内容的引用,此时就需要加入此条声明
  29. -dontskipnonpubliclibraryclasses
  30. -keepattributes EnclosingMethod
  31. # 指定不去忽略非公共的库的类的成員
  32. -dontskipnonpubliclibraryclassmembers
  33. # 不做预检验,preverify是proguard的四个步骤之一
  34. # Android不需要preverify,去掉这一步可以加快混淆速度
  35. -dontpreverify
  36. # 指定混淆时采用的算法,后面的参数是一个过滤器
  37. # 这个过滤器是谷歌推荐的算法,一般不改变
  38. -optimizations !code/simplification/artithmetic,!field/*,!class/merging/*
  39. # 保护代码中的Annotation不被混淆
  40. # 这在JSON实体映射时非常重要,比如fastJson
  41. -keepattributes *Annotation*
  42. ###排除所有注解类
  43. -keep class * extends java.lang.annotation.Annotation { *; }
  44. -keep interface * extends java.lang.annotation.Annotation { *; }
  45. -dontwarn javax.annotation.**
  46. # 避免混淆exp类,内部类,以及泛型
  47. # 这在JSON实体映射时非常重要,比如fastJson
  48. -keepattributes Exceptions,InnerClasses,Signature
  49. # 抛出异常时保留代码行号
  50. -keepattributes SourceFile,LineNumberTable
  51. #下面这行代码是 忽略警告,避免打包时某些警告出现
  52. -ignorewarnings
  53. # 保留所有的本地native方法不被混淆
  54. -keepclassmembers class * {
  55. native <methods>;
  56. }
  57. -keepclasseswithmembernames class * {
  58. native <methods>;
  59. }
  60. # 保留了继承自Activity、Application这些类的子类
  61. # 因为这些子类有可能被外部调用
  62. # 比如第一行就保证了所有Activity的子类不要被混淆
  63. -keep public class javax.**
  64. -keep public class android.webkit.**
  65. -keep public class * extends android.app.Activity
  66. -keep public class * extends android.app.Application
  67. -keep public class * extends android.app.Service
  68. -keep public class * extends android.content.BroadcastReceiver
  69. -keep public class * extends android.content.ContentProvider
  70. -keep public class * extends android.app.backup.BackupAgentHelper
  71. -keep public class * extends android.preference.Preference
  72. -keep public class * extends android.arch.lifecycle.AndroidViewModel
  73. -keep public class * extends android.view.View
  74. -keep public class com.android.vending.licensing.ILicensingService
  75. # 保留support下的所有类及其内部类
  76. -keep class android.support.** {*;}
  77. #support.v4/v7包不混淆
  78. #-keep public class * extends android.support.v4.**
  79. #-keep interface android.support.v4.app.** { *; }
  80. #-keep class android.support.v7.** { *; }
  81. #-keep public class * extends android.support.v7.**
  82. #-keep interface android.support.v7.app.** { *; }
  83. #-keep class androidx.recyclerview.widget.RecyclerView {*;}
  84. #-dontwarn android.support.** # 忽略警告
  85. -keep class com.google.android.material.** {*;}
  86. -keep class androidx.** {*;}
  87. -keep public class * extends androidx.**
  88. -keep interface androidx.** {*;}
  89. -dontwarn com.google.android.material.**
  90. -dontnote com.google.android.material.**
  91. -dontwarn androidx.**
  92. # 保留R下面的资源
  93. -keep class **.R$* {*;}
  94. #webview
  95. -dontwarn android.webkit.WebView
  96. #-----------处理js交互---------------
  97. -keepclassmembers class fqcn.of.javascript.interface.for.Webview {
  98. public *;
  99. }
  100. -keepclassmembers class * extends android.webkit.WebViewClient {
  101. public void *(android.webkit.WebView, java.lang.String, android.graphics.Bitmap);
  102. public boolean *(android.webkit.WebView, java.lang.String);
  103. }
  104. -keepclassmembers class * extends android.webkit.WebViewClient {
  105. public void *(android.webkit.WebView, java.lang.String);
  106. }
  107. -keepclassmembers class * {
  108. @android.webkit.JavascriptInterface <methods>;
  109. }
  110. -keepclassmembers public class com.swago.room.game.GamePlayDialog$JSLoad{
  111. <fields>;
  112. <methods>;
  113. public *;
  114. private *;
  115. }
  116. # 如果有引用android-support-v4.jar包,可以添加下面这行 ???
  117. -keep public class com.null.test.ui.fragment.** {*;}
  118. # 保留Activity中的方法参数是view的方法,
  119. # 从而我们在layout里面编写onClick就不会影响
  120. -keepclassmembers class * extends android.app.Activity {
  121. public void * (android.view.View);
  122. }
  123. # 枚举类不能被混淆
  124. -keep enum *
  125. -keepclassmembers enum * {
  126. public static **[] values();
  127. public static ** valueOf(java.lang.String);
  128. }
  129. -keepclassmembers class * implements java.io.Serializable {
  130. static final long serialVersionUID;
  131. static final java.io.ObjectStreamField[] serialPersistentFields;
  132. private void writeObject(java.io.ObjectOutputStream);
  133. private void readObject(java.io.ObjectInputStream);
  134. java.lang.Object writeReplace();
  135. java.lang.Object readResolve();
  136. }
  137. -keepnames class * implements android.os.Parcelable {
  138. public static final ** CREATOR;
  139. }
  140. ##---------------Begin: proguard configuration for Gson ----------
  141. # Gson uses generic type information stored in a class file when working with fields. Proguard
  142. # removes such information by default, so configure it to keep all of it.
  143. -keepattributes Signature
  144. # For using GSON @Expose annotation
  145. -keepattributes *Annotation*
  146. # Gson specific classes
  147. -dontwarn sun.misc.**
  148. #-keep class com.google.gson.stream.** { *; }
  149. # Application classes that will be serialized/deserialized over Gson
  150. -keep class com.google.gson.examples.android.model.** { <fields>; }
  151. # Prevent proguard from stripping interface information from TypeAdapter, TypeAdapterFactory,
  152. # JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
  153. -keep class * extends com.google.gson.TypeAdapter
  154. -keep class * implements com.google.gson.TypeAdapterFactory
  155. -keep class * implements com.google.gson.JsonSerializer
  156. -keep class * implements com.google.gson.JsonDeserializer
  157. # Prevent R8 from leaving Data object members always null
  158. -keepclassmembers,allowobfuscation class * {
  159. @com.google.gson.annotations.SerializedName <fields>;
  160. }
  161. # =========================== 混淆输出配置 ===========================
  162. # 有了verbose这句话,混淆后就会生成映射文件
  163. # 包含有类名->混淆后类名的映射关系
  164. # 然后使用printmapping指定映射文件的名称
  165. -verbose
  166. #记录生成的日志数据,gradle build时在本项目根目录输出
  167. #apk 包内所有 class 的内部结构
  168. -dump class_files.txt
  169. #未混淆的类和成員
  170. #-printseeds seeds.txt
  171. #列出从 apk 中删除的代码
  172. #-printusage unused.txt
  173. #混淆前后的映射
  174. -printmapping mapping.txt
  175. -keep class com.swago.baseswago.model.**{*;}
  176. -keep class com.swago.baseswago.util.**{*;}
  177. -keep class com.swago.room.bean.**{*;}
  178. -keep class com.swago.lib_country_picker.**{*;}
  179. -keep class com.tencent.imsdk.** { *; }
  180. -keepclassmembers class * implements androidx.viewbinding.ViewBinding {
  181. public static * inflate(android.view.LayoutInflater);
  182. }
  183. -keep class com.huantansheng.easyphotos.models.** { *; }
  184. -keep class com.bumptech.glide.request.RequestOptions {*;}
  185. -keep public class * implements com.bumptech.glide.module.GlideModule
  186. -keep class * extends com.bumptech.glide.module.AppGlideModule {
  187. <init>(...);
  188. }
  189. -keep public enum com.bumptech.glide.load.ImageHeaderParser$** {
  190. **[] $VALUES;
  191. public *;
  192. }
  193. -keep class com.bumptech.glide.load.data.ParcelFileDescriptorRewinder$InternalRewinder {
  194. *** rewind();
  195. }
  196. -keep class com.gyf.immersionbar.* {*;}
  197. -dontwarn com.gyf.immersionbar.**
  198. -keep class io.agora.**{*;}
  199. -keep class com.android.vending.billing.**
  200. -keep public class com.alibaba.android.arouter.routes.**{*;}
  201. -keep public class com.alibaba.android.arouter.facade.**{*;}
  202. -keep class * implements com.alibaba.android.arouter.facade.template.ISyringe{*;}
  203. -keep interface * implements com.alibaba.android.arouter.facade.template.IProvider
  204. -keep class * implements com.alibaba.android.arouter.facade.template.IProvider
  205. #svgplayer
  206. -keep class com.squareup.wire.** { *; }
  207. -keep class com.opensource.svgaplayer.proto.** { *; }
  208. #facebook
  209. -keep class com.facebook.applinks.** { *; }
  210. -keepclassmembers class com.facebook.applinks.** { *; }
  211. -keep class com.facebook.FacebookSdk { *; }
  212. -keep class com.huawei.hms.ads.** { *; }
  213. -keep class com.facebook.login.** { *; }
  214. -keep class com.uc.crashsdk.** { *; }
  215. -keep interface com.uc.crashsdk.** { *; }
  216. -keep class com.aliyun.sls.android.producer.* { *; }
  217. -keep interface com.aliyun.sls.android.producer.* { *; }
  218. -keep class com.aliyun.sls.android.** { *; }