Thursday, 1 December 2022

Proguard rules with Excel fail on release build - Android

Edit: Updated with dependencies

Dependencies:

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'

In my proguard file I have the following:

-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.** {*;}

This works fine in the debug build, but causes a crash when axcessing one of the methods in the release build.

The full stack trace:

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) 

Is there anything I am missing in my proguard file? I have tried various code snippets from Stack Overflow with no success.



from Proguard rules with Excel fail on release build - Android

No comments:

Post a Comment