Android Studio中的Apache POI库错误..? [英] Apache POI Libraries error in Android Studio..?
问题描述
我添加了5个Apache POI的jar文件,以便可以将文本另存为.docx文档,但我无法首先运行该应用程序,我的成绩为210错误,现在我有此错误,有人可以帮助我.. !我按照这个例子 https://www.tutorialspoint.com/apache_poi_word/apache_poi_word_quick_guide.htm
I added 5 jar files of Apache POI so that I can save an text as .docx document but I can't run the application first I had 210 error in the grade now i have this error can someone please help me ..!? i followed this example https://www.tutorialspoint.com/apache_poi_word/apache_poi_word_quick_guide.htm
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.example.mike.textword"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.0'
testCompile 'junit:junit:4.12'
compile files('libs/dom4j-1.6.jar')
compile files('libs/poi-3.16-beta2.jar')
compile files('libs/poi-ooxml-3.16-beta2.jar')
compile files('libs/poi-ooxml-schemas-3.16-beta2.jar')
compile files('libs/xmlbeans-2.6.0.jar')
compile 'com.android.support:multidex:1.0.1'
}
现在我有这个错误!
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:org/apache/xmlbeans/xml/stream/Location.class
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/apache/xmlbeans/xml/stream/Location.class
推荐答案
当前,由于直接使用Apache POI中的库时会遇到各种问题,因此Apache POI无法在您的Android Phone上使用. Android对jar类文件中的重复类更为严格,不幸的是XmlBeans在jar文件中具有此类重复类.
Currently Apache POI will not work on your Android Phone out of the box due to various problems that you will run into when using the libraries from Apache POI directly. Android is more strict about duplicate classes as part of the jar-files and unfortunately XmlBeans has such duplicate classes in it's jar-file.
有两个项目试图使在Android上使用Apache POI成为可能:
There are two projects that try to make it possible to use Apache POI on Android:
- https://github.com/andruhon/android5xlsx (对于Android 5)和 https://github.com/andruhon/AndroidReadXLSX (适用于Android 4),两者目前仍基于Apache POI 3.12
- https://github.com/centic9/poi-on-android/(适用于我维护的Android 5),可以使用更新版本的POI更轻松地重新编译,例如目前使用的是3.16-beta2
- https://github.com/andruhon/android5xlsx (for Android 5) and https://github.com/andruhon/AndroidReadXLSX (for Android 4), both are currently still based on Apache POI 3.12
- https://github.com/centic9/poi-on-android/ (for Android 5, maintained by me), which can be more easily recompiled with newer versions of POI, e.g. it uses 3.16-beta2 currently
这篇关于Android Studio中的Apache POI库错误..?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!