proguard-rules.pro 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  1. # Add project specific ProGuard rules here.
  2. # By default, the flags in this file are appended to flags specified
  3. # in D:\Program Files\Android\sdk/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. # ================================================================================================
  17. # =========================================== 混淆模板 ===========================================
  18. # ================================================================================================
  19. # ---------------------------------------- 输入/输出 选项 ----------------------------------------
  20. # 指定的jar将不被混淆
  21. # -libraryjars libs/fastjson-1.2.4.jar
  22. # 跳过(不混淆) jars中的 非public classes
  23. -dontskipnonpubliclibraryclasses
  24. # 不跳过(混淆) jars中的 非public classes 默认选项
  25. # -dontskipnonpubliclibraryclassmembers
  26. # ------------------------------------------- 优化选项 -------------------------------------------
  27. # 不优化(当使用该选项时,下面的选项均无效)
  28. -dontoptimize
  29. # 默认启用优化,根据 optimization_filter 指定要优化的文件
  30. # -optimizations optimization_filter
  31. -optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
  32. # 迭代优化的次数默认99次,一般迭代10次左右,代码已经不能再次优化了
  33. -optimizationpasses 5
  34. # ------------------------------------------- 压缩选项 -------------------------------------------
  35. # 不压缩(全局性的,即便使用了-keep 开启shrink,也无效)
  36. -dontshrink
  37. # ------------------------------------------ 预校验选项 ------------------------------------------
  38. # 不预校验
  39. -dontpreverify
  40. # ------------------------------------------- 通用选项 -------------------------------------------
  41. # 打印详细
  42. -verbose
  43. # 不打印某些错误
  44. # -dontnote android.support.v4.**
  45. # 不打印警告信息
  46. # -dontwarn android.support.v4.**
  47. # 忽略警告,继续执行
  48. -ignorewarnings
  49. # ------------------------------------------- 混淆选项 -------------------------------------------
  50. # 不混淆
  51. # -dontobfuscate
  52. # 不使用大小写混合类名
  53. -dontusemixedcaseclassnames
  54. # 指定重新打包,所有包重命名,这个选项会进一步模糊包名,将包里的类混淆成n个再重新打包到一个个的package中
  55. -flattenpackagehierarchy ''
  56. # 将包里的类混淆成n个再重新打包到一个统一的package中 会覆盖 flattenpackagehierarchy 选项
  57. -repackageclasses ''
  58. # 混淆时可能被移除下面这些东西,如果想保留,需要用该选项。对于一般注解处理如 -keepattributes *Annotation*
  59. # attribute_filter : Exceptions, Signature, Deprecated, SourceFile, SourceDir, LineNumberTable,
  60. # LocalVariableTable, LocalVariableTypeTable, Synthetic,
  61. # EnclosingMethod, RuntimeVisibleAnnotations, RuntimeInvisibleAnnotations, RuntimeVisibleParameterAnnotations,
  62. # RuntimeInvisibleParameterAnnotations, and AnnotationDefault.
  63. # -keepattributes *Annotation*
  64. # ---------------------------------------- 保持不变的选项 ----------------------------------------
  65. # 保持class_specification规则;若有[,modifier,...],则先启用它的规则
  66. # -keep [,modifier,...] class_specification
  67. # 保持类的成员:属性(可以是成员属性、类属性)、方法(可以是成员方法、类方法)
  68. # -keepclassmembers [,modifier,...]class_specification
  69. # 与-keep功能基本一致(经测试)
  70. # -keepclasseswithmembers [,modifier,...] class_specification
  71. # Short for -keep,allowshrinking class_specification
  72. # -keepnames class_specification
  73. # Short for -keepclassmembers,allowshrinking class_specification
  74. # -keepclassmembernames class_specification
  75. # Short for -keepclasseswithmembers,allowshrinking class_specification
  76. # -keepclasseswithmembernames class_specification
  77. # 打印匹配的-keep家族处理的 类和类成员列表,到标准输出。
  78. # -printseeds [filename]
  79. # ************************************************************************************************
  80. # ******************************************* COMMON *******************************************
  81. # ************************************************************************************************
  82. -keep public class * extends android.app.Activity
  83. -keep public class * extends android.app.Application
  84. -keep public class * extends android.app.Fragment
  85. -keep public class * extends android.app.Service
  86. -keep public class * extends android.content.BroadcastReceiver
  87. -keep public class * extends android.content.ContentProvider
  88. -keep public class * extends android.app.backup.BackupAgentHelper
  89. -keep public class * extends android.preference.Preference
  90. -keep public class com.google.vending.licensing.ILicensingService
  91. -keep public class com.android.vending.licensing.ILicensingService
  92. # 所有native的方法不混淆
  93. -keepclasseswithmembernames class * {
  94. native <methods>;
  95. }
  96. # 继承自View的构造方法不混淆
  97. -keep public class * extends android.view.View {
  98. public <init>(android.content.Context);
  99. public <init>(android.content.Context, android.util.AttributeSet);
  100. public <init>(android.content.Context, android.util.AttributeSet, int);
  101. public void set*(***);
  102. public *** get*();
  103. }
  104. # 枚举类不混淆
  105. -keepclassmembers enum * {
  106. public static **[] values();
  107. public static ** valueOf(java.lang.String);
  108. }
  109. # AIDL 文件不能去混淆
  110. -keep class * implements android.os.Parcelable {
  111. public static final android.os.Parcelable$Creator *;
  112. }
  113. # 保护 谷歌第三方 jar 包,界面特效
  114. -keep class android.support.v4.**
  115. -dontwarn android.support.v4.**
  116. -keepattributes *Annotation*
  117. -keepattributes *JavascriptInterface*
  118. -keep public class android.support.v7.widget.** { *; }
  119. -keep public class android.support.v7.internal.widget.** { *; }
  120. -keep public class android.support.v7.internal.view.menu.** { *; }
  121. -keep public class * extends android.support.v4.view.ActionProvider {
  122. public <init>(android.content.Context);
  123. }
  124. # 保持源文件和行号的信息,用于混淆后定位错误位置
  125. -keepattributes SourceFile,LineNumberTable
  126. # 保持签名
  127. -keepattributes Signature
  128. # 保持任意包名.R类的类成员属性。即保护R文件中的属性名不变
  129. -keepclassmembers class **.R$* {
  130. public static <fields>;
  131. }
  132. # 保护所有实体中的字段名称
  133. -keepclassmembers class * implements java.io.Serializable {
  134. <fields>;
  135. <methods>;
  136. }
  137. # ************************************************************************************************
  138. # ******************************************* CUSTOM *******************************************
  139. # ************************************************************************************************
  140. #添加自己的混淆规则:
  141. #1. 代码中使用了反射,如一些ORM框架的使用,需要保证类名 方法不变,不然混淆后,就反射不了
  142. #2. 使用GSON、fastjson等JSON解析框架所生成的对象类,生成的bean实体对象,内部大多是通过反射来生成,不能混淆
  143. #3. 引用了第三方开源框架或继承第三方SDK,如开源的okhttp网络访问框架,百度定位SDK等,在这些第三库的文档中 一般会给出"相应的"混淆规则,复制过来即可
  144. #4. 有用到WEBView的JS调用接口,真没用过这块, 不是很熟, 网上那个看到的
  145. #5. 继承了Serializable接口的类,在反序列画的时候,需要正确的类名等,在Android 中大多是实现 Parcelable 来序列化的
  146. #对于引用第三方包的情况,可以采用下面方式避免打包出错:
  147. #-libraryjars libs/aaa.jar
  148. #-dontwarn com.xx.yy.**
  149. #-keep class com.xx.yy.** { *;}
  150. # 指定无需混淆的jar包和so库
  151. #-libraryjars libs/aaa.jar
  152. ## GSON 2.2.4 specific rules ##
  153. # Gson uses generic type information stored in a class file when working with fields. Proguard
  154. # removes such information by default, so configure it to keep all of it.
  155. -keepattributes EnclosingMethod
  156. # Gson specific classes
  157. -keep class sun.misc.Unsafe { *; }
  158. -keep class com.google.gson.stream.** { *; }
  159. # 实体类 混淆keep规则
  160. -keep class com.google.common.base.**{ *; }
  161. -keep class com.beiyongjin.byg.module.home.dataModel.**{ *; }
  162. -keep class com.beiyongjin.byg.module.repay.dataModel.**{ *; }
  163. -keep class com.beiyongjin.byg.module.mine.dataModel.**{ *; }
  164. -keep class com.beiyongjin.byg.module.user.dataModel.**{ *; }
  165. -keep class com.beiyongjin.byg.module.home.viewModel.**{ *; }
  166. -keep class com.beiyongjin.byg.module.repay.viewModel.**{ *; }
  167. -keep class com.beiyongjin.byg.module.mine.viewModel.**{ *; }
  168. -keep class com.beiyongjin.byg.module.user.viewModel.**{ *; }
  169. -keep class com.beiyongjin.byg.views.spinnerwheel.**{ *; }
  170. -keep class com.erongdu.wireless.network.entity.**{ *; }
  171. # gilde 混淆keep规则
  172. -keep class com.bumptech.glide.integration.okhttp.OkHttpGlideModule
  173. -keep public class * implements com.bumptech.glide.module.GlideModule
  174. -keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** {
  175. **[] $VALUES;
  176. public *;
  177. }
  178. # banner 的混淆代码
  179. -keep class com.youth.banner.** { *; }
  180. # Retrofit 2.X 混淆keep规则
  181. -dontwarn retrofit2.**
  182. -keep class retrofit2.** { *; }
  183. -keepattributes Exceptions
  184. -keepclasseswithmembers class * {
  185. @retrofit2.http.* <methods>;
  186. }
  187. # OkHttp3 混淆keep规则
  188. -keep class okhttp3.** { *; }
  189. -keep interface okhttp3.** { *; }
  190. -dontwarn okhttp3.**
  191. # Okio 混淆keep规则
  192. -keep class sun.misc.Unsafe { *; }
  193. -dontwarn java.nio.file.*
  194. -dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
  195. -dontwarn okio.**
  196. # GreenDAO 混淆keep规则
  197. -keepclassmembers class * extends org.greenrobot.greendao.AbstractDao {
  198. public static java.lang.String TABLENAME;
  199. }
  200. -keep class **$Properties
  201. # SweetAlert 混淆keep规则
  202. -keep class cn.pedant.SweetAlert.Rotate3dAnimation {
  203. public <init>(...);
  204. }
  205. # ActivityRouter 混淆keep规则
  206. -keep class com.github.mzule.activityrouter.router.** { *; }
  207. # Bugtags 混淆keep规则
  208. -keepattributes LineNumberTable,SourceFile
  209. -keep class com.bugtags.library.** {*;}
  210. -dontwarn com.bugtags.library.**
  211. -keep class io.bugtags.** {*;}
  212. -dontwarn io.bugtags.**
  213. -dontwarn org.apache.http.**
  214. -dontwarn android.net.http.AndroidHttpClient
  215. # 商汤身份证卡片 混淆keep规则
  216. -keep class com.sensetime.** { *; }
  217. # 连连Demo混淆keep规则,如果使用了Demo中工具包com.yintong.pay.utils下面的类,请对应添加keep规则,否则混下会包签名错误
  218. -keep public class com.yintong.pay.utils.** {
  219. <fields>;
  220. <methods>;
  221. }
  222. # 连连混淆keep规则,请添加
  223. -keep class com.yintong.secure.activityproxy.PayIntro$LLJavascriptInterface{*;}
  224. # databinding混淆keep规则,请添加
  225. -keep class android.databinding.** { *; }
  226. -keepnames class * implements java.io.Serializable
  227. -keepclassmembers class * implements java.io.Serializable {
  228. static final long serialVersionUID;
  229. private static final java.io.ObjectStreamField[] serialPersistentFields;
  230. !static !transient <fields>;
  231. private void writeObject(java.io.ObjectOutputStream);
  232. private void readObject(java.io.ObjectInputStream);
  233. java.lang.Object writeReplace();
  234. java.lang.Object readResolve();
  235. }
  236. -keepattributes *Annotation*
  237. -keepattributes javax.xml.bind.annotation.*
  238. -keepattributes javax.annotation.processing.*
  239. -keepclassmembers class * extends java.lang.Enum { *; }
  240. -keepclasseswithmembernames class android.**
  241. -keepclasseswithmembernames interface android.**
  242. #-dontobfuscate
  243. -libraryjars <java.home>/lib/rt.jar
  244. -libraryjars <java.home>/lib/jce.jar
  245. -dontwarn
  246. # 友盟分享 混淆keep规则
  247. -dontshrink
  248. -dontoptimize
  249. -dontwarn com.google.android.maps.**
  250. -dontwarn android.webkit.WebView
  251. -dontwarn com.umeng.**
  252. -dontwarn com.tencent.weibo.sdk.**
  253. -dontwarn com.facebook.**
  254. -keep public class javax.**
  255. -keep public class android.webkit.**
  256. -dontwarn android.support.v4.**
  257. -keep enum com.facebook.**
  258. -keepattributes Exceptions,InnerClasses,Signature
  259. -keepattributes *Annotation*
  260. -keepattributes SourceFile,LineNumberTable
  261. -keep public interface com.facebook.**
  262. -keep public interface com.tencent.**
  263. -keep public interface com.umeng.socialize.**
  264. -keep public interface com.umeng.socialize.sensor.**
  265. -keep public interface com.umeng.scrshot.**
  266. -keep public class com.umeng.socialize.* {*;}
  267. -keep class com.facebook.**
  268. -keep class com.facebook.** { *; }
  269. -keep class com.umeng.scrshot.**
  270. -keep public class com.tencent.** {*;}
  271. -keep class com.umeng.socialize.sensor.**
  272. -keep class com.umeng.socialize.handler.**
  273. -keep class com.umeng.socialize.handler.*
  274. -keep class com.tencent.mm.sdk.modelmsg.WXMediaMessage {*;}
  275. -keep class com.tencent.mm.sdk.modelmsg.** implements com.tencent.mm.sdk.modelmsg.WXMediaMessage$IMediaObject {*;}
  276. #-keep class im.yixin.sdk.api.YXMessage {*;}
  277. #-keep class im.yixin.sdk.api.** implements im.yixin.sdk.api.YXMessage$YXMessageData{*;}
  278. #-dontwarn twitter4j.**
  279. #-keep class twitter4j.** { *; }
  280. #-keep class com.tencent.** {*;}
  281. #-dontwarn com.tencent.**
  282. -keep public class com.umeng.soexample.R$*{
  283. public static final int *;
  284. }
  285. -keep public class com.umeng.soexample.R$*{
  286. public static final int *;
  287. }
  288. -keep class com.tencent.open.TDialog$*
  289. -keep class com.tencent.open.TDialog$* {*;}
  290. -keep class com.tencent.open.PKDialog
  291. -keep class com.tencent.open.PKDialog {*;}
  292. -keep class com.tencent.open.PKDialog$*
  293. -keep class com.tencent.open.PKDialog$* {*;}
  294. #-keep class com.sina.** {*;}
  295. #-dontwarn com.sina.**
  296. #-keep class com.alipay.share.sdk.** {
  297. # *;
  298. #}
  299. -keepnames class * implements android.os.Parcelable {
  300. public static final ** CREATOR;
  301. }
  302. -keep class com.linkedin.** { *; }
  303. -keepattributes Signature
  304. #webView js调用混淆
  305. -keepclassmembers class com.erongdu.wireless.views.RdWebView {
  306. public *;
  307. }
  308. #保留annotation, 例如 @JavascriptInterface 等 annotation
  309. -keepattributes *Annotation*
  310. #保留跟 javascript相关的属性
  311. -keepattributes JavascriptInterface
  312. #保留JavascriptInterface中的方法
  313. -keepclassmembers class * {
  314. @android.webkit.JavascriptInterface <methods>;
  315. }
  316. #这个根据自己的project来设置,这个类用来与js交互,所以这个类中的 字段 ,方法, 等尽量保持
  317. -keepclassmembers public class com.erongdu.wireless.views.RDWebViewClient{
  318. <fields>;
  319. <methods>;
  320. public *;
  321. private *;
  322. }
  323. #这个根据自己的project来设置,这个类用来与js交互,所以这个类中的 字段 ,方法, 等尽量保持
  324. -keepclassmembers public class com.beiyongjin.byg.common.ui.WebViewCtrl{
  325. <fields>;
  326. <methods>;
  327. public *;
  328. private *;
  329. }
  330. #高德地图定位功能
  331. -keep class com.amap.api.location.**{*;}
  332. -keep class com.amap.api.fence.**{*;}
  333. -keep class com.autonavi.aps.amapapi.model.**{*;}
  334. #权限管理
  335. -keep class com.yanzhenjie.permission.**{ *; }
  336. #同盾
  337. -dontwarn android.os.**
  338. -dontwarn com.android.internal.**
  339. -keep class cn.tongdun.android.**{*;}
  340. #个推
  341. -dontwarn com.igexin.**
  342. -keep class com.igexin.** { *; }
  343. #EventBus
  344. -keepclassmembers class ** {
  345. public void onEvent*(**);
  346. }
  347. #支付宝
  348. #-keep class com.alipay.android.app.IAlixPay{*;}
  349. #-keep class com.alipay.android.app.IAlixPay$Stub{*;}
  350. #-keep class com.alipay.android.app.IRemoteServiceCallback{*;}
  351. #-keep class com.alipay.android.app.IRemoteServiceCallback$Stub{*;}
  352. #-keep class com.alipay.sdk.app.PayTask{ public *;}
  353. #-keep class com.alipay.sdk.app.AuthTask{ public *;}
  354. #-keep class com.alipay.sdk.app.H5PayCallback {
  355. # <fields>;
  356. # <methods>;
  357. #}
  358. -keep class com.alipay.android.phone.mrpc.core.** { *; }
  359. -keep class com.alipay.apmobilesecuritysdk.** { *; }
  360. -keep class com.alipay.mobile.framework.service.annotation.** { *; }
  361. -keep class com.alipay.mobilesecuritysdk.face.** { *; }
  362. -keep class com.alipay.tscenter.biz.rpc.** { *; }
  363. -keep class org.json.alipay.** { *; }
  364. -keep class com.alipay.tscenter.** { *; }
  365. -keep class com.ta.utdid2.** { *;}
  366. -keep class com.ut.device.** { *;}