XMLBeans Duplicate Class and Class Not Found Errors

▼魔方 西西 提交于 2019-12-11 03:23:29

问题


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


回答1:


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



回答2:


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




回答3:


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



来源:https://stackoverflow.com/questions/31251508/xmlbeans-duplicate-class-and-class-not-found-errors

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!