proguard-rules.pro 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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. # Gson反序列化用的数据传输类
  54. -keep class io.legado.app.model.translation.**{*;}
  55. -keep class io.legado.app.domain.model.DictPair{*;}
  56. -keep class io.legado.app.domain.model.BookDictionary{*;}
  57. -keep class io.legado.app.domain.model.TextChunk{*;}
  58. -keep class io.legado.app.domain.model.ModuleDef{*;}
  59. -keep class io.legado.app.domain.model.ModuleItem{*;}
  60. -keep class io.legado.app.domain.model.CustomSetItem{*;}
  61. -keep class io.legado.app.data.repository.GoogleTranslateResponse{*;}
  62. -keep class io.legado.app.data.repository.GoogleSentence{*;}
  63. -keep class io.legado.app.data.repository.GoogleSpell{*;}
  64. -keep class io.legado.app.data.repository.OpenAIResponse{*;}
  65. -keep class io.legado.app.data.repository.OpenAIChoice{*;}
  66. -keep class io.legado.app.data.repository.OpenAIMessage{*;}
  67. # hutool-core hutool-crypto
  68. -keep class
  69. !cn.hutool.core.util.RuntimeUtil,
  70. !cn.hutool.core.util.ClassLoaderUtil,
  71. !cn.hutool.core.util.ReflectUtil,
  72. !cn.hutool.core.util.SerializeUtil,
  73. !cn.hutool.core.util.ClassUtil,
  74. cn.hutool.core.codec.**,
  75. cn.hutool.core.util.**{*;}
  76. -keep class cn.hutool.crypto.**{*;}
  77. -dontwarn cn.hutool.**
  78. # 缓存 Cookie
  79. -keep class **.help.http.CookieStore{*;}
  80. -keep class **.help.CacheManager{*;}
  81. # StrResponse
  82. -keep class **.help.http.StrResponse{*;}
  83. # markwon
  84. -dontwarn org.commonmark.ext.gfm.**
  85. -keep class okhttp3.*{*;}
  86. -keep class okio.*{*;}
  87. -keep class com.jayway.jsonpath.*{*;}
  88. # LiveEventBus
  89. -keepclassmembers class androidx.lifecycle.LiveData {
  90. *** mObservers;
  91. *** mActiveCount;
  92. }
  93. -keepclassmembers class androidx.arch.core.internal.SafeIterableMap {
  94. *** size();
  95. *** putIfAbsent(...);
  96. }
  97. ## ChangeBookSourceDialog initNavigationView
  98. -keepclassmembers class androidx.appcompat.widget.Toolbar {
  99. *** mNavButtonView;
  100. }
  101. # FileDocExtensions.kt treeDocumentFileConstructor
  102. -keep class androidx.documentfile.provider.TreeDocumentFile {
  103. <init>(...);
  104. }
  105. # JsoupXpath
  106. -keep,allowobfuscation class * implements org.seimicrawler.xpath.core.AxisSelector{*;}
  107. -keep,allowobfuscation class * implements org.seimicrawler.xpath.core.NodeTest{*;}
  108. -keep,allowobfuscation class * implements org.seimicrawler.xpath.core.Function{*;}
  109. ## JSOUP
  110. -keep class org.jsoup.**{*;}
  111. -dontwarn org.jspecify.annotations.NullMarked
  112. ## ExoPlayer 反射设置ua 保证该私有变量不被混淆
  113. -keepclassmembers class androidx.media3.datasource.cache.CacheDataSource$Factory {
  114. *** upstreamDataSourceFactory;
  115. }
  116. ## ExoPlayer 如果还不能播放就取消注释这个
  117. # -keep class com.google.android.exoplayer2.** {*;}
  118. ## 对外提供api
  119. -keep class io.legado.app.api.ReturnData{*;}
  120. # Cronet
  121. -keepclassmembers class org.chromium.net.X509Util {
  122. *** sDefaultTrustManager;
  123. *** sTestTrustManager;
  124. }
  125. # Throwable
  126. -keepnames class * extends java.lang.Throwable
  127. -keepclassmembernames,allowobfuscation class * extends java.lang.Throwable{*;}
  128. # 忽略 Ktor 在 Android 上对 Java SE 管理类的引用
  129. -dontwarn java.lang.management.**
  130. -dontwarn io.ktor.util.debug.IntellijIdeaDebugDetector
  131. -keep,allowobfuscation class io.ktor.util.debug.** { *; }