XMLBeans Duplicate Class and Class Not Found Error

2019-07-07 14:56发布

I have been trying for days to get the Apache POI API to work, but I keep running into errors with the xmlbeans2.6.0 jar. First, whenever I tried to run my app, it would crash saying that there was a duplicate class, so I did the usual method of extracting all the files and converting those files back into a jar; however, now I get that this error:

java.lang.ClassNotFoundException:

Didn't find class "org.apache.xmlbeans.XmlOptions" on path: DexPathList[[zip file "/data/app/arcane.com.athletesunited-1/base.apk"]

Any thoughts?

Jacob

3条回答
【Aperson】
2楼-- · 2019-07-07 15:12

Apache POI will not work out of the box on Android. With the XML based formats you will run into a few issues with bare Apache POI libraries, partly because Android has some limitations and also because the XMLBeans jar file has duplicate class files among others.

There are currently at least two projects that wrap/adjust Apache POI for easier usage on Android:

  1. https://github.com/andruhon/android5xlsx (for Android 5) and https://github.com/andruhon/AndroidReadXLSX (for Android 4), both provide pre-packaged libraries of Apache POI, but both are currently still based on Apache POI 3.12
  2. https://github.com/centic9/poi-on-android/ (for Android 5, maintained by me), this one uses a different approach and allows to more easily re-build the packaged library with newer versions of Apache POI, e.g. it uses 3.15 currently
查看更多
不美不萌又怎样
3楼-- · 2019-07-07 15:25

it's unfortunately due to this issue https://issues.apache.org/jira/browse/XMLBEANS-499 which hasn't been fixed in... 3 years!!!

查看更多
Anthone
4楼-- · 2019-07-07 15:30

If any one wants to know the answer to this, it's simple: don't use Apache-POI, but instead use something like jexcel.

查看更多
登录 后发表回答