POI : duplicate entry: org/apache/xmlbeans/xml/str

2019-09-02 17:26发布

问题:

I am having problems to use Poi to read xlsx files in Android. In my gradle I have:

  • compile fileTree(dir: 'libs', include: '*.jar')
  • compile 'org.apache.poi:poi:3.14'
  • compile 'org.apache.poi:poi-ooxml:3.14'

In libs folder I have xmlbeans-2.6.0.jar. Previously I had the problem duplicate entry:

org/apache/xmlbeans/xml/stream/Location.class

but I get to solve with https://issues.apache.org/jira/browse/XMLBEANS-499

Now, I am getting the error duplicate entry:

org/apache/xmlbeans/xml/stream/BindigConfig.class

Can somebody help me?

回答1:

Update: There is now a newer version 3.0.1 of XmlBeans provided by the Apache POI PMC which should fix the duplicated classes, this version will be included with the upcoming Apache POI 4.0.0 as well

There is also a project https://github.com/centic9/poi-on-android/ which is more actively maintained. It provides a different approach of allowing to use Apache POI on Android via a shaded jar which contains all the required classes in one big jar that can be added to Android projects easily.


This is caused by duplicated class-files in the released version of the xmlbeans-jar file. Normal JDKs handle this gracefully, only the Android compiler fails on it.

There is a project which tries to provide fixed jars at https://github.com/andruhon/android5xlsx

Also there is discussion in Apache POI to fix the XMLBeans jar at https://bz.apache.org/bugzilla/show_bug.cgi?id=59268 (although it is actually a separate retired ASF-project).