proguard-rules.pro 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. ## Add project specific ProGuard rules here.
  2. ## By default, the flags in this file are appended to flags specified
  3. ## in D:\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. #
  8. ################################
  9. ##
  10. ## 公共部分(固定不变)
  11. ##
  12. ################################
  13. ##1.基本指令区
  14. ## 代码混淆压缩比,在0~7之间,默认为5,一般不做修改
  15. #-optimizationpasses 5
  16. ## 混合时不使用大小写混合,混合后的类名为小写
  17. #-dontusemixedcaseclassnames
  18. ## 指定不去忽略非公共库的类
  19. #-dontskipnonpubliclibraryclasses
  20. ## 这句话能够使我们的项目混淆后产生映射文件
  21. ## 包含有类名->混淆后类名的映射关系
  22. #-verbose
  23. ## 指定不去忽略非公共库的类成员
  24. #-dontskipnonpubliclibraryclassmembers
  25. ## 不做预校验,preverify是proguard的四个步骤之一,Android不需要preverify,去掉这一步能够加快混淆速度。
  26. #-dontpreverify
  27. ## 保留Annotation不混淆
  28. #-keepattributes *Annotation*,InnerClasses
  29. ## 避免混淆泛型
  30. #-keepattributes Signature
  31. ## 抛出异常时保留代码行号
  32. #-keepattributes SourceFile,LineNumberTable
  33. ## 指定混淆是采用的算法,后面的参数是一个过滤器
  34. ## 这个过滤器是谷歌推荐的算法,一般不做更改
  35. #-optimizations !code/simplification/cast,!field/*,!class/merging/*
  36. #
  37. ##2.默认保留区
  38. ## 保留我们使用的四大组件,自定义的Application等等这些类不被混淆
  39. ## 因为这些子类都有可能被外部调用
  40. #-keep public class * extends android.app.Activity
  41. #-keep public class * extends android.app.Application
  42. #-keep public class * extends android.app.Service
  43. #-keep public class * extends android.content.BroadcastReceiver
  44. #-keep public class * extends android.content.ContentProvider
  45. #-keep public class * extends android.app.backup.BackupAgentHelper
  46. #-keep public class * extends android.preference.Preference
  47. #-keep public class * extends android.view.View
  48. #-keep public class com.android.vending.licensing.ILicensingService
  49. ## 保留support下的所有类及其内部类
  50. #-keep class android.support.** {*;}
  51. ## 保留继承的
  52. #-keep public class * extends android.support.v4.**
  53. #-keep public class * extends android.support.v7.**
  54. #-keep public class * extends android.support.annotation.**
  55. ## 保留R下面的资源
  56. #-keep class **.R$* {*;}
  57. #
  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. #-keepclasseswithmembers class * {
  81. # public <init>(android.content.Context, android.util.AttributeSet);
  82. # public <init>(android.content.Context, android.util.AttributeSet, int);
  83. #}
  84. #
  85. ## 保留Parcelable序列化类不被混淆
  86. #-keep class * implements android.os.Parcelable {
  87. # public static final android.os.Parcelable$Creator *;
  88. #}
  89. ## 保留Serializable序列化的类不被混淆
  90. #-keepclassmembers class * implements java.io.Serializable {
  91. # static final long serialVersionUID;
  92. # private static final java.io.ObjectStreamField[] serialPersistentFields;
  93. # !static !transient <fields>;
  94. # !private <fields>;
  95. # !private <methods>;
  96. # private void writeObject(java.io.ObjectOutputStream);
  97. # private void readObject(java.io.ObjectInputStream);
  98. # java.lang.Object writeReplace();
  99. # java.lang.Object readResolve();
  100. #}
  101. ## 对于带有回调函数的onXXEvent、**On*Listener的,不能被混淆
  102. #-keepclassmembers class * {
  103. # void *(**On*Event);
  104. #}
  105. #
  106. ##3.webview
  107. #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
  108. # public *;
  109. #}
  110. #-keepclassmembers class * extends android.webkit.webViewClient {
  111. # public void *(android.webkit.WebView, java.lang.String, android.graphics.Bitmap);
  112. # public boolean *(android.webkit.WebView, java.lang.String);
  113. #}
  114. #-keepclassmembers class * extends android.webkit.webViewClient {
  115. # public void *(android.webkit.webView, jav.lang.String);
  116. #}
  117. ##移除Log类打印各个等级日志的代码,打正式包的时候可以做为禁log使用
  118. ##这里可以作为禁止log打印的功能使用,另外的一种实现方案是通过BuildConfig.DEBUG的变量来控制
  119. #-assumenosideeffects class android.util.Log {
  120. # public static *** v(...);
  121. # public static *** i(...);
  122. # public static *** d(...);
  123. # public static *** w(...);
  124. # public static *** e(...);
  125. #}
  126. #
  127. #
  128. ################################
  129. ##
  130. ## 第三方jar包
  131. ##
  132. ################################
  133. #-keep class com.uuzuche.lib_zxing.** {*;}
  134. #-keep class cc.cloudist.acplibrary.** {*;}
  135. #-keep class com.handmark.pulltorefresh.library.** {*;}
  136. #-keep class android.arch.core.internal.** {*;}
  137. #-keep class android.arch.lifecycle.** {*;}
  138. #-keep class com.alibaba.fastjson.** {*;}
  139. #-dontwarn com.alibaba.fastjson.**
  140. #-keep class android.support.graphics.drawable.** {*;}
  141. #-keep class com.facebook.stetho.** {*;}
  142. #-keep class javax.annotation.** {*;}
  143. #-keep class com.lidroid.xutils.** {*;}
  144. #-keep class okhttp3.** {*;}
  145. #-keep class okio.** {*;}
  146. #-dontwarn okio.**
  147. #-keep class org.apache.commons.cli.** {*;}
  148. #-keep class org.junit.** {*;}
  149. #-keep class junit.** {*;}
  150. #-keep class org.hamcrest.** {*;}
  151. #
  152. #-keep class sun.misc.Unsafe {*;}
  153. #-keep class com.google.gson.** {*;}
  154. #-keep class com.google.gson.stream.** {*;}
  155. #-keep class com.android.volley.** {*;}
  156. #
  157. #-keep class butterknife.** {*;}
  158. #-dontwarn butterknife.internal.**
  159. #-keep class **$$ViewBinder { *; }
  160. #
  161. ################################
  162. ##
  163. ## 自己的代码
  164. ## 引用的其他Module可以直接在app的这个混淆文件里配置
  165. ##
  166. ################################
  167. ##实体类
  168. #-keep class com.uas.xuslectronic.bean.** {*;}
  169. ##-keep .** {*;}