使用Excel的Profuard规则在发布版本中失败- Android

afdcj2ne  于 2022-12-09  发布在  Android
关注(0)|答案(2)|浏览(102)

bounty将在6天后过期。回答此问题可获得+100声望奖励。shko正在寻找标准答案:期望值:发布版本在使用Excel方法时不应该崩溃。我想要一个不那么通用的保留规则,而不是只保留我自己包之外的所有内容。
编辑:更新了依赖项

相关性:

implementation group: 'org.apache.poi', name: 'poi-ooxml', version: '3.17'
implementation group: 'org.apache.xmlbeans', name: 'xmlbeans', version: '3.1.0'
implementation 'com.fasterxml:aalto-xml:1.2.2'

在我的proguard文件中,我有以下内容:

-keep class org.apache.poi.** {*;}
-keep class org.apache.xmlbeans.** {*;}
-keep class com.fasterxml.** {*;}
-keep class com.microsoft.schemas.** {*;}
-keep class org.openxmlformats.** {*;}
-keep class org.openxmlformats.schemas.** {*;}
-keep class schemaorg_apache_xmlbeans.** {*;}

这在调试版本中运行良好,但在访问发布版本中的某个方法时会导致崩溃。
完整堆栈跟踪:

java.lang.ExceptionInInitializerError
    at org.apache.xmlbeans.XmlBeans.typeSystemForClassLoader(Unknown Source:0)
    at j7.a.a(SourceFile:2)
    at org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbook.<clinit>(SourceFile:1)
    at org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbook$Factory.newInstance(Unknown Source:0)
    at org.apache.poi.xssf.usermodel.XSSFWorkbook.onWorkbookCreate(SourceFile:1)
    at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(SourceFile:5)
    at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(SourceFile:1)
    at com.shervinkoushan.anyTracker.shared.utils.FileUtils.pointsToWorkBook(SourceFile:2)
    at com.shervinkoushan.anyTracker.shared.utils.FileUtils.dataPointsToExcelFile(SourceFile:1)
    at f9.k.invokeSuspend(SourceFile:17)
    at sa.a.resumeWith(SourceFile:3)
    at qd.o0.run(SourceFile:18)
    at xd.a$a.run(SourceFile:14)
Caused by: java.lang.IllegalStateException: Cannot load nodeToCursor: verify that xbean.jar is on the classpath
    at org.apache.xmlbeans.XmlBeans.buildMethod(SourceFile:4)
    at org.apache.xmlbeans.XmlBeans.buildNodeMethod(Unknown Source:18)
    at org.apache.xmlbeans.XmlBeans.buildNodeToCursorMethod(Unknown Source:4)
    at org.apache.xmlbeans.XmlBeans.<clinit>(SourceFile:11)
    at org.apache.xmlbeans.XmlBeans.typeSystemForClassLoader(Unknown Source:0) 
    at j7.a.a(SourceFile:2) 
    at org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbook.<clinit>(SourceFile:1) 
    at org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbook$Factory.newInstance(Unknown Source:0) 
    at org.apache.poi.xssf.usermodel.XSSFWorkbook.onWorkbookCreate(SourceFile:1) 
    at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(SourceFile:5) 
    at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(SourceFile:1) 
    at com.shervinkoushan.anyTracker.shared.utils.FileUtils.pointsToWorkBook(SourceFile:2) 
    at com.shervinkoushan.anyTracker.shared.utils.FileUtils.dataPointsToExcelFile(SourceFile:1) 
    at f9.k.invokeSuspend(SourceFile:17) 
    at sa.a.resumeWith(SourceFile:3) 
    at qd.o0.run(SourceFile:18) 
    at xd.a$a.run(SourceFile:14) 
Caused by: java.lang.NoSuchMethodException: org.apache.xmlbeans.impl.store.Locale.nodeToCursor [interface org.w3c.dom.Node]
    at java.lang.Class.getMethod(Class.java:2103)
    at java.lang.Class.getMethod(Class.java:1724)
    at org.apache.xmlbeans.XmlBeans.buildMethod(SourceFile:1)
    at org.apache.xmlbeans.XmlBeans.buildNodeMethod(Unknown Source:18) 
    at org.apache.xmlbeans.XmlBeans.buildNodeToCursorMethod(Unknown Source:4) 
    at org.apache.xmlbeans.XmlBeans.<clinit>(SourceFile:11) 
    at org.apache.xmlbeans.XmlBeans.typeSystemForClassLoader(Unknown Source:0) 
    at j7.a.a(SourceFile:2) 
    at org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbook.<clinit>(SourceFile:1) 
    at org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbook$Factory.newInstance(Unknown Source:0) 
    at org.apache.poi.xssf.usermodel.XSSFWorkbook.onWorkbookCreate(SourceFile:1) 
    at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(SourceFile:5) 
    at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(SourceFile:1) 
    at com.shervinkoushan.anyTracker.shared.utils.FileUtils.pointsToWorkBook(SourceFile:2) 
    at com.shervinkoushan.anyTracker.shared.utils.FileUtils.dataPointsToExcelFile(SourceFile:1) 
    at f9.k.invokeSuspend(SourceFile:17) 
    at sa.a.resumeWith(SourceFile:3) 
    at qd.o0.run(SourceFile:18) 

在我的proguard文件中有什么我遗漏的吗?我已经尝试了堆栈溢出的各种代码片段,都没有成功。

zazmityj

zazmityj1#

您可以使用-keep class !com.your.package.** { *; }将所有内容保存在您自己的包的文件之外。

u4dcyp6a

u4dcyp6a2#

如果您的min SDK version小于21,请使用此准则在项目中启用multidex

相关问题