proguard-rules.pro 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. -dontwarn com.tencent.bugly.**
  20. -keep public class com.tencent.bugly.**{*;}
  21. -optimizationpasses 5 # 指定代码的压缩级别
  22. -dontusemixedcaseclassnames # 是否使用大小写混合
  23. -dontpreverify # 混淆时是否做预校验
  24. -verbose # 混淆时是否记录日志
  25. -optimizations !code/simplification/arithmetic,!field/*,!class/merging/* # 混淆时所采用的算法
  26. #在此基础上,我们也可以使用Java的基本规则来保护特定类不被混淆,比如我们可以用extend,implement等这些Java规则。如下
  27. # 保留我们使用的四大组件,自定义的Application等等这些类不被混淆
  28. # 因为这些子类都有可能被外部调用
  29. # 避免混淆Annotation、内部类、泛型、匿名类
  30. -keepattributes *Annotation*,InnerClasses,Signature,EnclosingMethod
  31. -renamesourcefileattribute SourceFile
  32. # 抛出异常时保留代码行号
  33. -keepattributes SourceFile,LineNumberTable
  34. -keep public class * extends android.app.Activity # 保持哪些类不被混淆
  35. -keep public class * extends android.app.Application # 保持哪些类不被混淆
  36. -keep public class * extends android.app.Service # 保持哪些类不被混淆
  37. -keep public class * extends android.content.BroadcastReceiver # 保持哪些类不被混淆
  38. -keep public class * extends android.content.ContentProvider # 保持哪些类不被混淆
  39. -keep public class * extends android.app.backup.BackupAgentHelper # 保持哪些类不被混淆
  40. -keep public class * extends android.preference.Preference # 保持哪些类不被混淆
  41. #-keep public class com.android.vending.licensing.ILicensingService # 保持哪些类不被混淆
  42. #解决在6.0系统出现java.lang.InternalError
  43. -keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* {
  44. long producerIndex;
  45. long consumerIndex;
  46. }
  47. -keep class **$Properties
  48. -keep class *{*;}
  49. #assume no side effects:删除android.util.Log输出的日志
  50. -assumenosideeffects class android.util.Log {
  51. public static *** v(...);
  52. public static *** d(...);
  53. public static *** i(...);
  54. public static *** w(...);
  55. public static *** e(...);
  56. }
  57. # 保留support下的所有类及其内部类
  58. -keep class android.support.** {*;}
  59. # 保留继承的
  60. -keep public class * extends android.support.v4.**
  61. -keep public class * extends android.support.v7.**
  62. -keep public class * extends android.support.annotation.**
  63. # 保留R下面的资源
  64. -keep class **.R$* {*;}
  65. -keep class com.dlc.* {*;}
  66. # 保留在Activity中的方法参数是view的方法,
  67. # 这样以来我们在layout中写的onClick就不会被影响
  68. -keepclassmembers class * extends android.app.Activity{
  69. public void *(android.view.View);
  70. }
  71. # 保留枚举类不被混淆
  72. -keepclassmembers enum * {
  73. public static **[] values();
  74. public static ** valueOf(java.lang.String);
  75. }
  76. -keepclasseswithmembernames class * { # 保持 native 方法不被混淆
  77. native <methods>;
  78. }
  79. -keepclasseswithmembers class * { # 保持自定义控件类不被混淆
  80. public <init>(android.content.Context, android.util.AttributeSet);
  81. }
  82. -keepclasseswithmembers class * {# 保持自定义控件类不被混淆
  83. public <init>(android.content.Context, android.util.AttributeSet, int);
  84. }
  85. -keepclassmembers class * extends android.app.Activity { # 保持自定义控件类不被混淆
  86. public void *(android.view.View);
  87. }