proguard-rules.pro 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. #############################################
  2. #
  3. # 对于一些基本指令的添加
  4. #
  5. #############################################
  6. -optimizationpasses 5
  7. -dontusemixedcaseclassnames
  8. -dontskipnonpubliclibraryclasses
  9. -dontskipnonpubliclibraryclassmembers
  10. -dontpreverify
  11. -verbose
  12. -printmapping proguardMapping.txt
  13. -optimizations !code/simplification/cast,!field/*,!class/merging/*
  14. -keepattributes *Annotation*,InnerClasses
  15. -keepattributes EnclosingMethod, InnerClasses
  16. -keepattributes *Annotation*
  17. -keepattributes Signature
  18. -keepattributes LineNumberTable
  19. -renamesourcefileattribute SourceFile
  20. # 重新包装所有重命名的包并放在给定的单一包中
  21. -flattenpackagehierarchy androidx.base
  22. # 将包里的类混淆成n个再重新打包到一个统一的package中 会覆盖flattenpackagehierarchy选项
  23. -repackageclasses androidx.base
  24. # 把混淆类中的方法名也混淆了
  25. -useuniqueclassmembernames
  26. #############################################
  27. #
  28. # Android开发中一些需要保留的公共部分
  29. #
  30. #############################################
  31. # 保留我们使用的四大组件,自定义的Application等等这些类不被混淆
  32. # 因为这些子类都有可能被外部调用
  33. -keep public class * extends android.app.Activity
  34. -keep public class * extends android.app.Appliction
  35. -keep public class * extends android.app.Service
  36. -keep public class * extends android.content.BroadcastReceiver
  37. -keep public class * extends android.content.ContentProvider
  38. -keep public class * extends android.app.backup.BackupAgentHelper
  39. -keep public class * extends android.preference.Preference
  40. -keep public class * extends android.view.View
  41. -keep public class com.android.vending.licensing.ILicensingService
  42. # 保留support下的所有类及其内部类
  43. -keep class android.support.** {*;}
  44. # 保留继承的
  45. -keep public class * extends android.support.v4.**
  46. -keep public class * extends android.support.v7.**
  47. -keep public class * extends android.support.annotation.**
  48. -keep class com.google.android.material.** { *; }
  49. -dontwarn com.google.android.material.**
  50. -dontnote com.google.android.material.**
  51. -dontwarn androidx.**
  52. -keep class androidx.** { *; }
  53. -keep interface androidx.** { *; }
  54. #-keep public class * extends androidx.**
  55. -keep class org.xmlpull.v1.** {*;}
  56. # 保留R下面的资源
  57. -keep class **.R$* {*;}
  58. # 保留本地native方法不被混淆
  59. -keepclasseswithmembernames class * {
  60. native <methods>;
  61. }
  62. # 保留在Activity中的方法参数是view的方法,
  63. # 这样以来我们在layout中写的onClick就不会被影响
  64. -keepclassmembers class * extends android.app.Activity{
  65. public void *(android.view.View);
  66. }
  67. # 保留枚举类不被混淆
  68. -keepclassmembers enum * {
  69. public static **[] values();
  70. public static ** valueOf(java.lang.String);
  71. }
  72. # 保留我们自定义控件(继承自View)不被混淆
  73. -keep public class * extends android.view.View{
  74. *** get*();
  75. void set*(***);
  76. public <init>(android.content.Context);
  77. public <init>(android.content.Context, android.util.AttributeSet);
  78. public <init>(android.content.Context, android.util.AttributeSet, int);
  79. }
  80. -keep public class * extends androidx.recyclerview.widget.RecyclerView$LayoutManager{
  81. *** get*();
  82. void set*(***);
  83. public <init>(android.content.Context);
  84. public <init>(android.content.Context, android.util.AttributeSet);
  85. public <init>(android.content.Context, android.util.AttributeSet, int);
  86. }
  87. -keep class com.orhanobut.hawk.** { *; }
  88. # 保留Parcelable序列化类不被混淆
  89. -keep class * implements android.os.Parcelable {
  90. public static final android.os.Parcelable$Creator *;
  91. }
  92. # 保留Serializable序列化的类不被混淆
  93. -keepclassmembers class * implements java.io.Serializable {
  94. static final long serialVersionUID;
  95. private static final java.io.ObjectStreamField[] serialPersistentFields;
  96. !static !transient <fields>;
  97. !private <fields>;
  98. !private <methods>;
  99. private void writeObject(java.io.ObjectOutputStream);
  100. private void readObject(java.io.ObjectInputStream);
  101. java.lang.Object writeReplace();
  102. java.lang.Object readResolve();
  103. }
  104. # 对于带有回调函数的onXXEvent、**On*Listener的,不能被混淆
  105. -keepclassmembers class * {
  106. void *(**On*Event);
  107. void *(**On*Listener);
  108. }
  109. #xwalk
  110. -keep class org.xwalk.core.** { *; }
  111. -keep class org.crosswalk.engine.** { *; }
  112. -keep class org.chromium.** { *; }
  113. -dontwarn android.view.**
  114. -dontwarn android.media.**
  115. -dontwarn org.chromium.**
  116. #okhttp
  117. -dontwarn okhttp3.**
  118. -keep class okhttp3.**{*;}
  119. #okio
  120. -dontwarn okio.**
  121. -keep class okio.**{*;}
  122. #loadsir
  123. -dontwarn com.kingja.loadsir.**
  124. -keep class com.kingja.loadsir.** {*;}
  125. #gson
  126. # Gson specific classes
  127. -dontwarn sun.misc.**
  128. #-keep class com.google.gson.stream.** { *; }
  129. # Application classes that will be serialized/deserialized over Gson
  130. -keep class com.google.gson.examples.android.model.** { <fields>; }
  131. # Prevent proguard from stripping interface information from TypeAdapter, TypeAdapterFactory,
  132. # JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
  133. -keep class * extends com.google.gson.TypeAdapter
  134. -keep class * implements com.google.gson.TypeAdapterFactory
  135. -keep class * implements com.google.gson.JsonSerializer
  136. -keep class * implements com.google.gson.JsonDeserializer
  137. # Prevent R8 from leaving Data object members always null
  138. -keepclassmembers,allowobfuscation class * {
  139. @com.google.gson.annotations.SerializedName <fields>;
  140. }
  141. #xstream
  142. -keep class com.thoughtworks.xstream.converters.extended.SubjectConverter { *; }
  143. -keep class com.thoughtworks.xstream.converters.extended.ThrowableConverter { *; }
  144. -keep class com.thoughtworks.xstream.converters.extended.StackTraceElementConverter { *; }
  145. -keep class com.thoughtworks.xstream.converters.extended.CurrencyConverter { *; }
  146. -keep class com.thoughtworks.xstream.converters.extended.RegexPatternConverter { *; }
  147. -keep class com.thoughtworks.xstream.converters.extended.CharsetConverter { *; }
  148. -keep class com.thoughtworks.xstream.** { *; }
  149. #eventbus
  150. -keepclassmembers class * {
  151. @org.greenrobot.eventbus.Subscribe <methods>;
  152. }
  153. -keep enum org.greenrobot.eventbus.ThreadMode { *; }
  154. # And if you use AsyncExecutor:
  155. -keepclassmembers class * extends org.greenrobot.eventbus.util.ThrowableFailureEvent {
  156. <init>(java.lang.Throwable);
  157. }
  158. #bugly
  159. -dontwarn com.tencent.bugly.**
  160. -keep public class com.tencent.bugly.**{*;}
  161. -keep class android.support.**{*;}
  162. #dkplayer
  163. -keep class com.dueeeke.videoplayer.** { *; }
  164. -dontwarn com.dueeeke.videoplayer.**
  165. # IjkPlayer
  166. -keep class tv.danmaku.ijk.** { *; }
  167. -dontwarn tv.danmaku.ijk.**
  168. # ExoPlayer
  169. -keep class com.google.android.exoplayer2.** { *; }
  170. -dontwarn com.google.android.exoplayer2.**
  171. # 实体类
  172. #-keep class com.github.tvbox.osc.bean.** { *; }
  173. #CardView
  174. -keep class com.github.tvbox.osc.ui.tv.widget.card.**{*;}
  175. #ViewObj
  176. -keep class com.github.tvbox.osc.ui.tv.widget.ViewObj{
  177. <methods>;
  178. }
  179. -keep class com.github.catvod.crawler.*{*;}