2016-11-04 28 views
0

我試圖將Apache POI添加到我的項目中來創建電子表格。apache poi-ooxml 3.15不允許我運行Android項目

我已經添加了Apache POI到我的...的gradle

compile 'org.apache.poi:poi-ooxml:3.15' 

最初,這提出了一個錯誤 「執行失敗的任務 ':應用程序:transformResourcesWithmergejavaResForDebug'。」 - 非常相似,this question

添加以下到我的...的gradle

packagingOptions { 
    exclude 'META-INF/LICENSE' 
} 

現在,這將創建下列...

Information:Gradle tasks [:app:clean, :app:generateDebugSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:generateDebugAndroidTestSources, :app:assembleDebug] 
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class 
Error:(org.apache.xmlbeans.XmlBeans$1) that doesn't come with an 
Error:associated EnclosingMethod attribute. This class was probably produced by a 
Error:compiler that did not target the modern .class file format. The recommended 
Error:solution is to recompile the class from source, using an up-to-date compiler 
Error:and without specifying any "-target" type options. The consequence of ignoring 
Error:this warning is that reflective operations on this class will incorrectly 
Error:indicate that it is *not* an inner class. 
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class 
Error:(org.apache.xmlbeans.XmlSimpleList$1) that doesn't come with an 
Error:associated EnclosingMethod attribute. This class was probably produced by a 
Error:compiler that did not target the modern .class file format. The recommended 
Error:solution is to recompile the class from source, using an up-to-date compiler 
Error:and without specifying any "-target" type options. The consequence of ignoring 
Error:this warning is that reflective operations on this class will incorrectly 
Error:indicate that it is *not* an inner class. 
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class 
Error:(org.apache.xmlbeans.XmlSimpleList$2) that doesn't come with an 
Error:associated EnclosingMethod attribute. This class was probably produced by a 
Error:compiler that did not target the modern .class file format. The recommended 
Error:solution is to recompile the class from source, using an up-to-date compiler 
Error:and without specifying any "-target" type options. The consequence of ignoring 
Error:this warning is that reflective operations on this class will incorrectly 
Error:indicate that it is *not* an inner class. 
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class 
Error:(org.apache.xmlbeans.impl.inst2xsd.RussianDollStrategy$1) that doesn't come with an 
Error:associated EnclosingMethod attribute. This class was probably produced by a 
Error:compiler that did not target the modern .class file format. The recommended 
Error:solution is to recompile the class from source, using an up-to-date compiler 
Error:and without specifying any "-target" type options. The consequence of ignoring 
Error:this warning is that reflective operations on this class will incorrectly 
Error:indicate that it is *not* an inner class. 
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class 
Error:(org.apache.xmlbeans.impl.inst2xsd.util.Type$1) that doesn't come with an 
Error:associated EnclosingMethod attribute. This class was probably produced by a 
Error:compiler that did not target the modern .class file format. The recommended 
Error:solution is to recompile the class from source, using an up-to-date compiler 
Error:and without specifying any "-target" type options. The consequence of ignoring 
Error:this warning is that reflective operations on this class will incorrectly 
Error:indicate that it is *not* an inner class. 
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class 
Error:(org.apache.xmlbeans.impl.jam.JamUtils$1) that doesn't come with an 
Error:associated EnclosingMethod attribute. This class was probably produced by a 
Error:compiler that did not target the modern .class file format. The recommended 
Error:solution is to recompile the class from source, using an up-to-date compiler 
Error:and without specifying any "-target" type options. The consequence of ignoring 
Error:this warning is that reflective operations on this class will incorrectly 
Error:indicate that it is *not* an inner class. 
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class 
Error:(org.apache.xmlbeans.impl.regex.SchemaRegularExpression$1) that doesn't come with an 
Error:associated EnclosingMethod attribute. This class was probably produced by a 
Error:compiler that did not target the modern .class file format. The recommended 
Error:solution is to recompile the class from source, using an up-to-date compiler 
Error:and without specifying any "-target" type options. The consequence of ignoring 
Error:this warning is that reflective operations on this class will incorrectly 
Error:indicate that it is *not* an inner class. 
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class 
Error:(org.apache.xmlbeans.impl.regex.SchemaRegularExpression$2) that doesn't come with an 
Error:associated EnclosingMethod attribute. This class was probably produced by a 
Error:compiler that did not target the modern .class file format. The recommended 
Error:solution is to recompile the class from source, using an up-to-date compiler 
Error:and without specifying any "-target" type options. The consequence of ignoring 
Error:this warning is that reflective operations on this class will incorrectly 
Error:indicate that it is *not* an inner class. 
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class 
Error:(org.apache.xmlbeans.impl.regex.SchemaRegularExpression$3) that doesn't come with an 
Error:associated EnclosingMethod attribute. This class was probably produced by a 
Error:compiler that did not target the modern .class file format. The recommended 
Error:solution is to recompile the class from source, using an up-to-date compiler 
Error:and without specifying any "-target" type options. The consequence of ignoring 
Error:this warning is that reflective operations on this class will incorrectly 
Error:indicate that it is *not* an inner class. 
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class 
Error:(org.apache.xmlbeans.impl.schema.SchemaTypeLoaderImpl$SchemaTypeLoaderCache$1) that doesn't come with an 
Error:associated EnclosingMethod attribute. This class was probably produced by a 
Error:compiler that did not target the modern .class file format. The recommended 
Error:solution is to recompile the class from source, using an up-to-date compiler 
Error:and without specifying any "-target" type options. The consequence of ignoring 
Error:this warning is that reflective operations on this class will incorrectly 
Error:indicate that it is *not* an inner class. 
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class 
Error:(org.apache.xmlbeans.impl.store.CharUtil$1) that doesn't come with an 
Error:associated EnclosingMethod attribute. This class was probably produced by a 
Error:compiler that did not target the modern .class file format. The recommended 
Error:solution is to recompile the class from source, using an up-to-date compiler 
Error:and without specifying any "-target" type options. The consequence of ignoring 
Error:this warning is that reflective operations on this class will incorrectly 
Error:indicate that it is *not* an inner class. 
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class 
Error:(org.apache.xmlbeans.impl.store.Locale$1) that doesn't come with an 
Error:associated EnclosingMethod attribute. This class was probably produced by a 
Error:compiler that did not target the modern .class file format. The recommended 
Error:solution is to recompile the class from source, using an up-to-date compiler 
Error:and without specifying any "-target" type options. The consequence of ignoring 
Error:this warning is that reflective operations on this class will incorrectly 
Error:indicate that it is *not* an inner class. 
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class 
Error:(org.apache.xmlbeans.impl.tool.CodeGenUtil$1) that doesn't come with an 
Error:associated EnclosingMethod attribute. This class was probably produced by a 
Error:compiler that did not target the modern .class file format. The recommended 
Error:solution is to recompile the class from source, using an up-to-date compiler 
Error:and without specifying any "-target" type options. The consequence of ignoring 
Error:this warning is that reflective operations on this class will incorrectly 
Error:indicate that it is *not* an inner class. 
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class 
Error:(org.apache.xmlbeans.impl.tool.CodeGenUtil$ThreadedReader$1) that doesn't come with an 
Error:associated EnclosingMethod attribute. This class was probably produced by a 
Error:compiler that did not target the modern .class file format. The recommended 
Error:solution is to recompile the class from source, using an up-to-date compiler 
Error:and without specifying any "-target" type options. The consequence of ignoring 
Error:this warning is that reflective operations on this class will incorrectly 
Error:indicate that it is *not* an inner class. 
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class 
Error:(org.apache.xmlbeans.impl.tool.SchemaCodeGenerator$1) that doesn't come with an 
Error:associated EnclosingMethod attribute. This class was probably produced by a 
Error:compiler that did not target the modern .class file format. The recommended 
Error:solution is to recompile the class from source, using an up-to-date compiler 
Error:and without specifying any "-target" type options. The consequence of ignoring 
Error:this warning is that reflective operations on this class will incorrectly 
Error:indicate that it is *not* an inner class. 
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class 
Error:(org.apache.xmlbeans.impl.tool.SchemaResourceManager$1) that doesn't come with an 
Error:associated EnclosingMethod attribute. This class was probably produced by a 
Error:compiler that did not target the modern .class file format. The recommended 
Error:solution is to recompile the class from source, using an up-to-date compiler 
Error:and without specifying any "-target" type options. The consequence of ignoring 
Error:this warning is that reflective operations on this class will incorrectly 
Error:indicate that it is *not* an inner class. 
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class 
Error:(org.apache.xmlbeans.impl.tool.XsbDumper$1) that doesn't come with an 
Error:associated EnclosingMethod attribute. This class was probably produced by a 
Error:compiler that did not target the modern .class file format. The recommended 
Error:solution is to recompile the class from source, using an up-to-date compiler 
Error:and without specifying any "-target" type options. The consequence of ignoring 
Error:this warning is that reflective operations on this class will incorrectly 
Error:indicate that it is *not* an inner class. 
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class 
Error:(org.apache.xmlbeans.impl.validator.ValidatingXMLInputStream$1) that doesn't come with an 
Error:associated EnclosingMethod attribute. This class was probably produced by a 
Error:compiler that did not target the modern .class file format. The recommended 
Error:solution is to recompile the class from source, using an up-to-date compiler 
Error:and without specifying any "-target" type options. The consequence of ignoring 
Error:this warning is that reflective operations on this class will incorrectly 
Error:indicate that it is *not* an inner class. 
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class 
Error:(org.apache.xmlbeans.impl.xpathgen.XPathGenerator$1) that doesn't come with an 
Error:associated EnclosingMethod attribute. This class was probably produced by a 
Error:compiler that did not target the modern .class file format. The recommended 
Error:solution is to recompile the class from source, using an up-to-date compiler 
Error:and without specifying any "-target" type options. The consequence of ignoring 
Error:this warning is that reflective operations on this class will incorrectly 
Error:indicate that it is *not* an inner class. 
Error:Uncaught translation error: java.lang.IllegalArgumentException: already added: Lorg/apache/xmlbeans/xml/stream/Location; 
Error:Uncaught translation error: java.lang.IllegalArgumentException: already added: Lorg/apache/xmlbeans/xml/stream/ReferenceResolver; 
Error:Uncaught translation error: java.lang.IllegalArgumentException: already added: Lorg/apache/xmlbeans/xml/stream/XMLEvent; 
Error:Uncaught translation error: java.lang.IllegalArgumentException: already added: Lorg/apache/xmlbeans/xml/stream/XMLInputStream; 
Error:Uncaught translation error: java.lang.IllegalArgumentException: already added: Lorg/apache/xmlbeans/xml/stream/XMLName; 
Error:Uncaught translation error: java.lang.IllegalArgumentException: already added: Lorg/apache/xmlbeans/xml/stream/XMLStreamException; 
Error:Uncaught translation error: java.lang.IllegalArgumentException: already added: Lorg/apache/xmlbeans/xml/stream/utils/NestedThrowable; 
Error:Uncaught translation error: java.lang.IllegalArgumentException: already added: Lorg/apache/xmlbeans/xml/stream/utils/NestedThrowable$Util; 
Error:8 errors; aborting 
Error:Execution failed for task ':app:transformClassesWithDexForDebug'. 
> com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Return code 1 for dex process 
Information:BUILD FAILED 
Information:Total time: 8.167 secs 
Information:162 errors 
Information:0 warnings 
Information:See complete output in console 

我不知道如何從進步這裏?我試圖按照我見過的其他一些問題的指示,但無濟於事。

回答

2

由於您在直接使用Apache POI庫時遇到的各種問題,Apache POI將無法在開箱即可使用。作爲jar文件的一部分,Android對它所允許的內容更加嚴格。

有一些項目,使它們能夠使用大多數的Apache POI的Android上:

  1. https://github.com/andruhon/android5xlsx(Android設備5)和https://github.com/andruhon/AndroidReadXLSX(針對Android 4),兩者目前還在基於Apache POI 3.12
  2. https://github.com/centic9/poi-on-android/(對於Android 5,由我維護),可以更容易地使用更新版本的POI重新編譯,例如它目前使用3.15