2014-09-21 95 views
6

我遇到了apache poi excel api(xlsx)的问题。我正在使用android studio,并且已经将poi库添加到“libs”文件夹中。出于某种原因,这个错误会弹出(见下文)。我将如何解决这个问题?能否请你解释你是如何确定这个问题的?包含Apache POI时出现Android重复类错误

xmlbeans-2.6.0,poi-ooxml-schemas-3.10.1-20140818,poi-ooxml-3.10.1-20140818,poi-3.10.1-20140818,log4j-1.2.13,junit-4.11, dom4j-1.6.1,commons-logging-1.1,commons-codec-1.5

谢谢!

我的build.gradle如下所示(不包括通用其他的东西)...

dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') }

android { packagingOptions { exclude 'META-INF/LICENSE' exclude 'META-INF/NOTICE' exclude 'META-INF/LICENSE.txt' exclude 'META-INF/NOTICE.txt' } }

我app.iml有没有重复的条目要么...

错误

Error:Class org.apache.xmlbeans.xml.stream.Location has already been added to output. Please remove duplicate copies. compiler that did not target the modern .class file format. The recommended (org.apache.log4j.chainsaw.ControlPanel$1) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a solution is to recompile the class from source, using an up-to-date compiler 1 error; aborting

+0

你解决了吗? – 2016-02-19 07:08:45

回答

1

Maven Central的xmlbeans 2.6 JAR包含一些重复的类条目。 XMLBeans JIRA有一个issue open的问题。在他们发布一个新的JAR之前,我想我要解压该jar,它会覆盖重复项,然后重新压缩并将其放入我的libs目录中。

1

请注意,在Android上使用Apache POI时可能遇到一些问题。 XmlBeans中的重复类目前只能通过重新打包jar来避免。

目前有两个项目试图为您解决大部分问题,包括将所有类(包括任何依赖关系)重新打包到单个jar文件中,以便于部署。还有一些着色是为了避免Android不允许的javax-namespace问题。

  1. https://github.com/andruhon/android5xlsx
  2. https://github.com/centic9/poi-on-android/(由我mainted)

第一种目前基于POI 3.12,而第二可与POI的较新版本更容易地重新编译。

相关问题