proguard-rules.pro 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. # 代码混淆压缩比,在0~7之间,默认为5,一般不下需要修改
  20. -optimizationpasses 5
  21. ## 混淆时不使用大小写混合,混淆后的类名为小写
  22. ## windows下的同学还是加入这个选项吧(windows大小写不敏感)
  23. -dontusemixedcaseclassnames
  24. #
  25. ## 指定不去忽略非公共的库的类
  26. ## 默认跳过,有些情况下编写的代码与类库中的类在同一个包下,并且持有包中内容的引用,此时就需要加入此条声明
  27. -dontskipnonpubliclibraryclasses
  28. #
  29. ## 指定不去忽略非公共的库的类的成员
  30. -dontskipnonpubliclibraryclassmembers
  31. # 不做预检验,preverify是proguard的四个步骤之一
  32. # Android不需要preverify,去掉这一步可以加快混淆速度
  33. -dontpreverify
  34. # 有了verbose这句话,混淆后就会生成映射文件
  35. -verbose
  36. #apk 包内所有 class 的内部结构
  37. -dump class_files.txt
  38. #未混淆的类和成员
  39. -printseeds seeds.txt
  40. #列出从 apk 中删除的代码
  41. -printusage unused.txt
  42. #混淆前后的映射
  43. -printmapping mapping.txt
  44. # 指定混淆时采用的算法,后面的参数是一个过滤器
  45. # 这个过滤器是谷歌推荐的算法,一般不改变
  46. -optimizations !code/simplification/artithmetic,!field/*,!class/merging/*
  47. # 保护代码中的Annotation不被混淆
  48. # 这在JSON实体映射时非常重要,比如fastJson
  49. -keepattributes *Annotation*
  50. # 避免混淆泛型
  51. # 这在JSON实体映射时非常重要,比如fastJson
  52. -keepattributes Signature
  53. # 抛出异常时保留代码行号
  54. -keepattributes SourceFile,LineNumberTable
  55. # 实体类不混淆
  56. -keep class com.emato.ich.entity.** {*;}
  57. -keep class com.emato.ich.entity.vo.** {*;}
  58. # 不需要混淆的安卓类
  59. -keep public class * extends android.app.Fragment
  60. -keep public class * extends android.app.Activity
  61. -keep public class * extends android.app.Application
  62. -keep public class * extends android.app.Service
  63. -keep public class * extends android.content.BroadcastReceiver
  64. -keep public class * extends android.preference.Preference
  65. -keep public class * extends android.content.ContentProvider
  66. -keep public class * extends android.app.backup.BackupAgentHelper
  67. -keep public class * extends android.preference.Preference
  68. -keep public class * extends android.view.View
  69. # support下所有类及其内部类
  70. -keep class android.support.** {*;}
  71. -dontwarn android.support.**
  72. -keep interface android.support.** { *; }
  73. # androidx
  74. -keep class androidx.** {*;}
  75. -keep interface androidx.** {*;}
  76. -keep public class * extends androidx.**
  77. -dontwarn androidx.**
  78. # support v4/7库
  79. -keep public class * extends android.support.v4.**
  80. -keep public class * extends android.support.v7.**
  81. -keep public class * extends android.support.annotation.**
  82. # support design库
  83. -dontwarn android.support.design.**
  84. -keep class android.support.design.** { *; }
  85. -keep interface android.support.design.** { *; }
  86. -keep public class android.support.design.R$* { *; }
  87. # androidx
  88. -keep class com.google.android.material.** {*;}
  89. -dontwarn com.google.android.material.**
  90. -dontnote com.google.android.material.**
  91. # 资源文件
  92. -keep class **.R$* {*;}
  93. # 避免layout中onClick方法混淆(android:onclick="onClick")
  94. -keepclassmembers class * extends android.app.Activity{
  95. public void *(android.view.View);
  96. }
  97. # 避免回调函数 onXXEvent混淆
  98. -keepclassmembers class * {
  99. void *(*Event);
  100. }
  101. # 避免枚举混淆
  102. -keepclassmembers enum * {
  103. public static **[] values();
  104. public static ** valueOf(java.lang.String);
  105. }
  106. # Native方法不混淆
  107. -keepclasseswithmembernames class * {
  108. native <methods>;
  109. }
  110. # 避免Parcelable混淆
  111. -keep class * implements android.os.Parcelable {
  112. public static final android.os.Parcelable$Creator *;
  113. }
  114. # 避免Serializable接口的子类中指定的某些成员变量和方法混淆
  115. -keepclassmembers class * implements java.io.Serializable {
  116. static final long serialVersionUID;
  117. private static final java.io.ObjectStreamField[] serialPersistentFields;
  118. !static !transient <fields>;
  119. private void writeObject(java.io.ObjectOutputStream);
  120. private void readObject(java.io.ObjectInputStream);
  121. java.lang.Object writeReplace();
  122. java.lang.Object readResolve();
  123. }
  124. # 避免okhttp3混淆
  125. -dontwarn com.squareup.okhttp3.**
  126. -keep class com.squareup.okhttp3.** { *;}
  127. -dontwarn okio.**
  128. # 避免小铁sdk混淆
  129. -keep class com.cherry.sdk.controller.** { *; }
  130. -keep class com.cherry.sdk.controller.callback.** { *; }
  131. -keep class com.cherry.sdk.controller.command.** { *; }
  132. -keep class com.cherry.sdk.controller.data.** { *; }
  133. -keep class com.cherry.sdk.controller.module.** { *; }
  134. -keep class com.cherry.sdk.controller.utils.** { *; }