【发布时间】:2020-12-13 18:27:14
【问题描述】:
我已完全构建了已在 Google Play 上被人们使用的应用。 目前在我的待办事项清单上是启用 pro-guard 并启用代码缩小和混淆。
我尝试启用它,但在我看来,缩小会破坏我正在努力理解的代码。
我能够启动应用程序的登录屏幕,它工作正常并让我登录,但是,一旦加载个人资料页面,就会出现此错误,我不能再做任何事情了。
错误是:
javax.xml.stream.FactoryFinder
这是我的build.gradle
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
我的 proguard-rules.pro 是默认的,只是我多加了一行,所以它看起来像这样:
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
-keepattributes LineNumberTable,SourceFile
请帮帮我。
【问题讨论】:
-
您很可能错过了一些
-keep应用程序使用的反射规则。如果在运行时找不到您提到的类,则添加-keep class javax.xml.stream.FactoryFinder { *; }可能会有所帮助。但是,如果您可以提供有关实际异常/堆栈跟踪的更多信息,那么您将更容易看到您需要仔细查看的内容。如果你还没有看一下developer.android.com/studio/build/shrink-code。 -
@sgjesse 好吧,你真是个天才。我发现这是由 Martyn Vysny 使用的
Konsume-XML库引起的。我所做的正是您使用该确切命令所说的内容,然后又出现了另一个错误。所以我使用了同一条线,但使用了另一个类和woila!有效。非常感谢。如果可以,请发布一个实际答案,以便我可以将其标记为已回答,因为您是要解决的问题。提到我必须添加的这两个类:-keep class javax.xml.stream.FactoryFinder { *; }-keep class com.bea.xml.stream.MXParserFactory { *; } -
很高兴听到他们找到了根本原因。我已经添加了一个答案并将这个报告给了 konsume-xml 的开发者。
标签: android proguard android-r8