Using com.bea.xml.stream package on android

Check FAQ #18:

This error indicates that the class XMLEventFactory does not provide
functionality which POI is depending upon. There can be a number of
different reasons for this:

Outdated xml-apis.jar, stax-apis.jar or xercesImpl.jar:

  • These libraries were required with Java 5 and lower, but are not actually required with spec-compliant Java 6 implementations, so try
    removing those libraries from your classpath. If this is not possible,
    try upgrading to a newer version of those jar files.

You probably need to exclude the stax:stax-api dependency through the build system that you use. I just solved a similar problem (same stack trace but from Groovy) by applying this method.

UPDATE:
It is best if you use the dependencies from a Maven repository, it will largely simplify your dependencies section:

dependencies {
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile 'com.android.support:multidex:1.0.0'
    compile ('org.apache.poi:poi-ooxml:3.12') {
        exclude group: 'stax', module: 'stax-api'
    }
}

You can now also remove the extra libraries that you have under the libs directory.

The Apache POI FAQ answer indicates that stax may not be needed at all for some Java versions, especially above 6.

Leave a Comment