proguard-rules.pro 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. # Add project specific ProGuard rules here.
  2. # By default, the flags in this file are appended to flags specified
  3. # in D:\AndroidSDK/tools/proguard/proguard-android.txt
  4. # You can edit the include path and order by changing the proguardFiles
  5. # directive in build.gradle.
  6. #
  7. # For more details, see
  8. # http://developer.android.com/guide/developing/tools/proguard.html
  9. # Add any project specific keep options here:
  10. # If your project uses WebView with JS, uncomment the following
  11. # and specify the fully qualified class name to the JavaScript interface
  12. # class:
  13. #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
  14. # public *;
  15. #}
  16. # Uncomment this to preserve the line number information for
  17. # debugging stack traces.
  18. #-keepattributes SourceFile,LineNumberTable
  19. # If you keep the line number information, uncomment this to
  20. # hide the original source file name.
  21. #-renamesourcefileattribute SourceFile
  22. #------------------------------------------主项目混淆规则----------------------------------------------
  23. #实体类不参与混淆
  24. -keep class com.goldze.mvvmhabit.entity.** { *; }
  25. #tkrefreshlayout
  26. -keep class com.lcodecore.tkrefreshlayout.** { *; }
  27. -dontwarn com.lcodecore.tkrefreshlayout.**
  28. #-------------------------------------------MVVMHabit混淆规则----------------------------------------------
  29. #---------------------------------1.实体类---------------------------------
  30. -keep class me.goldze.mvvmhabit.http.BaseResponse { *; }
  31. #-------------------------------------------------------------------------
  32. #--------------------------------2.第三方包-------------------------------
  33. #support
  34. -keep class android.support.** { *; }
  35. -keep interface android.support.** { *; }
  36. -dontwarn android.support.**
  37. #databinding
  38. -keep class android.databinding.** { *; }
  39. -dontwarn android.databinding.**
  40. #annotation
  41. -keep class android.support.annotation.** { *; }
  42. -keep interface android.support.annotation.** { *; }
  43. #retrofit
  44. -dontwarn retrofit2.**
  45. -keep class retrofit2.** { *; }
  46. -keepattributes Signature
  47. -keepattributes Exceptions
  48. #gson
  49. -keepattributes Signature
  50. -keepattributes *Annotation*
  51. -keep class sun.misc.Unsafe { *; }
  52. -keep class com.google.gson.stream.** { *; }
  53. -keep class com.sunloto.shandong.bean.** { *; }
  54. #glide
  55. -keep public class * implements com.bumptech.glide.module.AppGlideModule
  56. -keep public class * implements com.bumptech.glide.module.LibraryGlideModule
  57. -keep class com.bumptech.glide.** { *; }
  58. -keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** {
  59. **[] $VALUES;
  60. public *;
  61. }
  62. #glide-transformations
  63. -keep class jp.wasabeef.glide.transformations.** {*;}
  64. -dontwarn jp.wasabeef.glide.transformations.**
  65. #okhttp
  66. -keepattributes Signature
  67. -keepattributes *Annotation*
  68. -keep class com.squareup.okhttp.** { *; }
  69. -keep interface com.squareup.okhttp.** { *; }
  70. -keep class okhttp3.** { *; }
  71. -keep interface okhttp3.** { *; }
  72. -dontwarn com.squareup.okhttp.**
  73. -dontwarn okhttp3.**
  74. -dontwarn okio.**
  75. #RxJava RxAndroid
  76. -dontwarn rx.*
  77. -dontwarn sun.misc.**
  78. -keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* {
  79. long producerIndex;
  80. long consumerIndex;
  81. }
  82. -keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef {
  83. rx.internal.util.atomic.LinkedQueueNode producerNode;
  84. }
  85. -keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueConsumerNodeRef {
  86. rx.internal.util.atomic.LinkedQueueNode consumerNode;
  87. }
  88. #RxLifecycle
  89. -keep class com.trello.rxlifecycle2.** { *; }
  90. -keep interface com.trello.rxlifecycle2.** { *; }
  91. -dontwarn com.trello.rxlifecycle2.**
  92. #RxPermissions
  93. -keep class com.tbruyelle.rxpermissions2.** { *; }
  94. -keep interface com.tbruyelle.rxpermissions2.** { *; }
  95. #material-dialogs
  96. -keep class com.afollestad.materialdialogs.** { *; }
  97. -dontwarn om.afollestad.materialdialogs.**
  98. #=====================bindingcollectionadapter=====================
  99. -keep class me.tatarka.bindingcollectionadapter.** { *; }
  100. -dontwarn me.tatarka.bindingcollectionadapter.**
  101. #---------------------------------------------------------------------------
  102. #---------------------------------3.与js互相调用的类------------------------
  103. #无
  104. #----------------------------------------------------------------------------
  105. #---------------------------------4.反射相关的类和方法-----------------------
  106. -keep public class * extends me.goldze.mvvmhabit.base.BaseActivity{ *; }
  107. -keep public class * extends me.goldze.mvvmhabit.base.BaseFragment{ *; }
  108. -keep public class * extends me.goldze.mvvmhabit.binding.command.BindingCommand{ *; }
  109. -keep public class * extends me.goldze.mvvmhabit.binding.command.ResponseCommand{ *; }
  110. #----------------------------------------------------------------------------
  111. #---------------------------------5.自定义控件------------------------------
  112. -keep class me.goldze.mvvmhabit.widget.** { *; }
  113. #----------------------------------------------------------------------------
  114. #---------------------------------6.其他定制区-------------------------------
  115. #native方法不被混淆
  116. -keepclasseswithmembernames class * {
  117. native <methods>;
  118. }
  119. #Parcelable 不被混淆
  120. -keep class * implements android.os.Parcelable {
  121. public static final android.os.Parcelable$Creator *;
  122. }
  123. #Serializable 不被混淆
  124. -keepnames class * implements java.io.Serializable
  125. #Serializable 不被混淆并且enum 类也不被混淆
  126. -keepclassmembers class * implements java.io.Serializable {
  127. static final long serialVersionUID;
  128. private static final java.io.ObjectStreamField[] serialPersistentFields;
  129. !static !transient <fields>;
  130. !private <fields>;
  131. !private <methods>;
  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. #保持枚举 enum 类不被混淆 如果混淆报错,建议直接使用上面的 -keepclassmembers class * implements java.io.Serializable即可
  138. -keepclassmembers enum * {
  139. public static **[] values();
  140. public static ** valueOf(java.lang.String);
  141. }
  142. -keepclassmembers class * {
  143. public void *ButtonClicked(android.view.View);
  144. }
  145. #不混淆资源类
  146. -keepclassmembers class **.R$* {
  147. public static <fields>;
  148. }
  149. #保持类中的所有方法名
  150. -keepclassmembers class * {
  151. public <methods>;
  152. private <methods>;
  153. }
  154. #----------------------------------------------------------------------------
  155. #---------------------------------基本指令区---------------------------------
  156. # 抑制警告
  157. -ignorewarnings
  158. #指定代码的压缩级别
  159. -optimizationpasses 5
  160. #包名不混合大小写
  161. -dontusemixedcaseclassnames
  162. #不去忽略非公共的库类
  163. -dontskipnonpubliclibraryclasses
  164. #指定不去忽略非公共库的类成员
  165. -dontskipnonpubliclibraryclassmembers
  166. #优化 不优化输入的类文件
  167. -dontoptimize
  168. #预校验
  169. -dontpreverify
  170. #混淆时是否记录日志
  171. -verbose
  172. # 混淆时所采用的算法
  173. -optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
  174. #混淆包路径
  175. -repackageclasses ''
  176. -flattenpackagehierarchy ''
  177. #保护注解
  178. -keepattributes *Annotation*
  179. #避免混淆泛型 如果混淆报错建议关掉
  180. -keepattributes Signature
  181. #保留SourceFile和LineNumber属性
  182. -keepattributes SourceFile,LineNumberTable
  183. #忽略警告
  184. #-ignorewarning
  185. #----------记录生成的日志数据,gradle build时在本项目根目录输出---------
  186. #apk 包内所有 class 的内部结构
  187. -dump class_files.txt
  188. #未混淆的类和成员
  189. -printseeds seeds.txt
  190. #列出从 apk 中删除的代码
  191. -printusage unused.txt
  192. #混淆前后的映射
  193. -printmapping mapping.txt
  194. #----------------------------------------------------------------------------
  195. #---------------------------------默认保留区---------------------------------
  196. -keep public class * extends android.app.Activity
  197. -keep public class * extends android.app.Application
  198. -keep public class * extends android.app.Service
  199. -keep public class * extends android.content.BroadcastReceiver
  200. -keep public class * extends android.content.ContentProvider
  201. -keep public class * extends android.app.backup.BackupAgentHelper
  202. -keep public class * extends android.preference.Preference
  203. -keep public class * extends android.view.View
  204. -keep public class com.android.vending.licensing.ILicensingService
  205. -keep class android.support.** {*;}
  206. -keep public class * extends android.view.View{
  207. *** get*();
  208. void set*(***);
  209. public <init>(android.content.Context);
  210. public <init>(android.content.Context, android.util.AttributeSet);
  211. public <init>(android.content.Context, android.util.AttributeSet, int);
  212. }
  213. -keepclasseswithmembers class * {
  214. public <init>(android.content.Context, android.util.AttributeSet);
  215. public <init>(android.content.Context, android.util.AttributeSet, int);
  216. }
  217. -keepclassmembers class * implements java.io.Serializable {
  218. static final long serialVersionUID;
  219. private static final java.io.ObjectStreamField[] serialPersistentFields;
  220. private void writeObject(java.io.ObjectOutputStream);
  221. private void readObject(java.io.ObjectInputStream);
  222. java.lang.Object writeReplace();
  223. java.lang.Object readResolve();
  224. }
  225. -keep class **.R$* {
  226. *;
  227. }
  228. -keepclassmembers class * {
  229. void *(**On*Event);
  230. }
  231. #----------------------------------------------------------------------------
  232. #---------------------------------webview------------------------------------
  233. -keepclassmembers class fqcn.of.javascript.interface.for.Webview {
  234. public *;
  235. }
  236. -keepclassmembers class * extends android.webkit.WebViewClient {
  237. public void *(android.webkit.WebView, java.lang.String, android.graphics.Bitmap);
  238. public boolean *(android.webkit.WebView, java.lang.String);
  239. }
  240. -keepclassmembers class * extends android.webkit.WebViewClient {
  241. public void *(android.webkit.WebView, jav.lang.String);
  242. }
  243. #----------------------------------------------------------------------------
  244. #----------------------------------------------------------------------------
  245. #百度
  246. -keep class com.baidu.ocr.sdk.**{*;}
  247. -dontwarn com.baidu.ocr.**
  248. -dontwarn com.baidu.idl.**
  249. -keep class com.baidu.idl.** { *; }
  250. -dontwarn com.baidu.vis.**
  251. -keep class com.baidu.vis.** { *; }
  252. -dontwarn com.baidu.liantian.**
  253. -keep class com.baidu.liantian.** { *; }
  254. -dontwarn com.baidu.protect.**
  255. -keep class com.baidu.protect.** { *; }
  256. -dontwarn com.baidu.ocr.**
  257. -keep class com.baidu.ocr.** { *; }
  258. # 混淆时保留TengineKit相关类和成员
  259. -keep class com.tengine.** { *; }
  260. #大华没有提供混淆文档,猜测是这么
  261. -dontwarn com.company.PlaySDK.**
  262. -keep class com.company.PlaySDK.** { *; }
  263. -dontwarn com.company.NetSDK.**
  264. -keep class com.company.NetSDK.** { *; }
  265. -dontwarn com.company.CodecSDK.**
  266. -keep class com.company.CodecSDK.** { *; }
  267. -dontwarn com.example.demo_sdk.entity.**
  268. -keep class com.example.demo_sdk.entity.** { *; }
  269. -dontwarn com.mm.android.dhproxy.client.**
  270. -keep class com.mm.android.dhproxy.client.** { *; }