poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nolan Darilek <no...@thewordnerd.info>
Subject Reading/writing DocX on Android
Date Sun, 12 Oct 2014 02:11:38 GMT
Hello,

I'm having a very hard time trying to use XWPFDocument on Android. Seems
like I've read everything I can find from Google on the subject, but am
still hitting an issue. In particular, here's part of the exception I'm
getting when I try to write a DocX from an Android app:

E/AndroidRuntime( 2553): java.lang.NoSuchMethodError:
avax.xml.stream.XMLEventFactory.newFactory

E/AndroidRuntime( 2553):     at
org.apache.poi.openxml4j.opc.internal.marshallers.PackagePropertiesMarshaller.<clinit>(PackagePropertiesMarshaller.java:45)

E/AndroidRuntime( 2553):     at
org.apache.poi.openxml4j.opc.OPCPackage.init(OPCPackage.java:161)

E/AndroidRuntime( 2553):     at
org.apache.poi.openxml4j.opc.OPCPackage.<init>(OPCPackage.java:141)

E/AndroidRuntime( 2553):     at
org.apache.poi.openxml4j.opc.Package.<init>(Package.java:37)

E/AndroidRuntime( 2553):     at
org.apache.poi.openxml4j.opc.ZipPackage.<init>(ZipPackage.java:65)

E/AndroidRuntime( 2553):     at
org.apache.poi.openxml4j.opc.OPCPackage.create(OPCPackage.java:337)

E/AndroidRuntime( 2553):     at
org.apache.poi.xwpf.usermodel.XWPFDocument.newPackage(XWPFDocument.java:256)

E/AndroidRuntime( 2553):     at
org.apache.poi.xwpf.usermodel.XWPFDocument.<init>(XWPFDocument.java:129)

I understand the issues on Android are 2-fold. 1: the method limit. I
haven't seemed to hit that yet, so I haven't needed to shrink the POI jars.

2. The use of javax.* namespaces. Many of the solutions I saw on Google
involved manually opening the jars and replacing "javax" with something
else, like "avax". For this I used Jarjar and the Gradle plugin for
same, with a rule like:

"rule javax.** avax.@1"

The resulting fat jar appears to have its javax namespace renamed, and
indeed, I can't find the string "javax" anywhere when grepping through
the directories.

I'm also not sure if I need to manually install stax-api. It appears to
be installed as a POI dependency, but installing stax:stax-api:1.0.1
doesn't seem to make much of a difference.

Any idea as to why I'm getting this NoSuchMethodError? Guessing it has
to be something found on the JVM but not Dalvik, but I can't figure out
what that is and am quickly approaching my wits' end. Do I have to do
anything to tell POI to use the javax.xml.* facilities provided by
stax-api and not expect to find them on the VM running it? Or is there
something else I'm missing?

Thanks.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Mime
View raw message