proguard-rules.pro 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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. # 缓存 Cookie
  68. -keep class **.help.http.CookieStore{*;}
  69. -keep class **.help.CacheManager{*;}
  70. # StrResponse
  71. -keep class **.help.http.StrResponse{*;}
  72. # markwon
  73. -dontwarn org.commonmark.ext.gfm.**
  74. -keep class okhttp3.*{*;}
  75. -keep class okio.*{*;}
  76. -keep class com.jayway.jsonpath.*{*;}
  77. # LiveEventBus
  78. -keepclassmembers class androidx.lifecycle.LiveData {
  79. *** mObservers;
  80. *** mActiveCount;
  81. }
  82. -keepclassmembers class androidx.arch.core.internal.SafeIterableMap {
  83. *** size();
  84. *** putIfAbsent(...);
  85. }
  86. ## ChangeBookSourceDialog initNavigationView
  87. -keepclassmembers class androidx.appcompat.widget.Toolbar {
  88. *** mNavButtonView;
  89. }
  90. # FileDocExtensions.kt treeDocumentFileConstructor
  91. -keep class androidx.documentfile.provider.TreeDocumentFile {
  92. <init>(...);
  93. }
  94. # JsoupXpath
  95. -keep,allowobfuscation class * implements org.seimicrawler.xpath.core.AxisSelector{*;}
  96. -keep,allowobfuscation class * implements org.seimicrawler.xpath.core.NodeTest{*;}
  97. -keep,allowobfuscation class * implements org.seimicrawler.xpath.core.Function{*;}
  98. ## JSOUP
  99. -keep class org.jsoup.**{*;}
  100. -dontwarn org.jspecify.annotations.NullMarked
  101. ## ExoPlayer 反射设置ua 保证该私有变量不被混淆
  102. -keepclassmembers class androidx.media3.datasource.cache.CacheDataSource$Factory {
  103. *** upstreamDataSourceFactory;
  104. }
  105. ## ExoPlayer 如果还不能播放就取消注释这个
  106. # -keep class com.google.android.exoplayer2.** {*;}
  107. ## 对外提供api
  108. -keep class io.legado.app.api.ReturnData{*;}
  109. # Cronet
  110. -keepclassmembers class org.chromium.net.X509Util {
  111. *** sDefaultTrustManager;
  112. *** sTestTrustManager;
  113. }
  114. # Throwable
  115. -keepnames class * extends java.lang.Throwable
  116. -keepclassmembernames,allowobfuscation class * extends java.lang.Throwable{*;}
  117. # 忽略 Ktor 在 Android 上对 Java SE 管理类的引用
  118. -dontwarn java.lang.management.**
  119. -dontwarn io.ktor.util.debug.IntellijIdeaDebugDetector
  120. -keep,allowobfuscation class io.ktor.util.debug.** { *; }