proguard-rules.pro 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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.kts.
  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. # 混合时不使用大小写混合,混合后的类名为小写
  20. -dontusemixedcaseclassnames
  21. # 这句话能够使我们的项目混淆后产生映射文件
  22. # 包含有类名->混淆后类名的映射关系
  23. -verbose
  24. # 保留Annotation不混淆
  25. -keepattributes *Annotation*,InnerClasses
  26. # 避免混淆泛型
  27. -keepattributes Signature
  28. # 指定混淆是采用的算法,后面的参数是一个过滤器
  29. # 这个过滤器是谷歌推荐的算法,一般不做更改
  30. -optimizations !code/simplification/cast,!field/*,!class/merging/*
  31. -flattenpackagehierarchy
  32. #############################################
  33. #
  34. # Android开发中一些需要保留的公共部分
  35. #
  36. #############################################
  37. # 屏蔽错误Unresolved class name
  38. #noinspection ShrinkerUnresolvedReference
  39. # 移除Log类打印各个等级日志的代码,打正式包的时候可以做为禁log使用,这里可以作为禁止log打印的功能使用
  40. # 记得proguard-android.txt中一定不要加-dontoptimize才起作用
  41. # 另外的一种实现方案是通过BuildConfig.DEBUG的变量来控制
  42. -assumenosideeffects class android.util.Log {
  43. public static int v(...);
  44. public static int i(...);
  45. public static int w(...);
  46. public static int d(...);
  47. public static int e(...);
  48. }
  49. # 保持js引擎调用的java类
  50. -keep class * extends io.legado.app.help.JsExtensions{*;}
  51. # 数据类
  52. -keep class **.data.entities.**{*;}
  53. # hutool-core hutool-crypto
  54. -keep class
  55. !cn.hutool.core.util.RuntimeUtil,
  56. !cn.hutool.core.util.ClassLoaderUtil,
  57. !cn.hutool.core.util.ReflectUtil,
  58. !cn.hutool.core.util.SerializeUtil,
  59. !cn.hutool.core.util.ClassUtil,
  60. cn.hutool.core.codec.**,
  61. cn.hutool.core.util.**{*;}
  62. -keep class cn.hutool.crypto.**{*;}
  63. -dontwarn cn.hutool.**
  64. # 缓存 Cookie
  65. -keep class **.help.http.CookieStore{*;}
  66. -keep class **.help.CacheManager{*;}
  67. # StrResponse
  68. -keep class **.help.http.StrResponse{*;}
  69. # markwon
  70. -dontwarn org.commonmark.ext.gfm.**
  71. -keep class okhttp3.*{*;}
  72. -keep class okio.*{*;}
  73. -keep class com.jayway.jsonpath.*{*;}
  74. # LiveEventBus
  75. -keepclassmembers class androidx.lifecycle.LiveData {
  76. *** mObservers;
  77. *** mActiveCount;
  78. }
  79. -keepclassmembers class androidx.arch.core.internal.SafeIterableMap {
  80. *** size();
  81. *** putIfAbsent(...);
  82. }
  83. ## ChangeBookSourceDialog initNavigationView
  84. -keepclassmembers class androidx.appcompat.widget.Toolbar {
  85. *** mNavButtonView;
  86. }
  87. # FileDocExtensions.kt treeDocumentFileConstructor
  88. -keep class androidx.documentfile.provider.TreeDocumentFile {
  89. <init>(...);
  90. }
  91. # JsoupXpath
  92. -keep,allowobfuscation class * implements org.seimicrawler.xpath.core.AxisSelector{*;}
  93. -keep,allowobfuscation class * implements org.seimicrawler.xpath.core.NodeTest{*;}
  94. -keep,allowobfuscation class * implements org.seimicrawler.xpath.core.Function{*;}
  95. ## JSOUP
  96. -keep class org.jsoup.**{*;}
  97. -dontwarn org.jspecify.annotations.NullMarked
  98. ## ExoPlayer 反射设置ua 保证该私有变量不被混淆
  99. -keepclassmembers class androidx.media3.datasource.cache.CacheDataSource$Factory {
  100. *** upstreamDataSourceFactory;
  101. }
  102. ## ExoPlayer 如果还不能播放就取消注释这个
  103. # -keep class com.google.android.exoplayer2.** {*;}
  104. ## 对外提供api
  105. -keep class io.legado.app.api.ReturnData{*;}
  106. # Cronet
  107. -keepclassmembers class org.chromium.net.X509Util {
  108. *** sDefaultTrustManager;
  109. *** sTestTrustManager;
  110. }
  111. # Throwable
  112. -keepnames class * extends java.lang.Throwable
  113. -keepclassmembernames,allowobfuscation class * extends java.lang.Throwable{*;}