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
应用插件:'com.android.application'安卓 {compileSdkVersion 25构建工具版本25.0.0"默认配置{applicationId "com.example.mike.textword"minSdkVersion 19目标SDK版本25版本代码 1版本名称1.0"testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"multiDexEnabled = 真}构建类型{释放 {minifyEnabled falseproguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'}}}依赖{编译文件树(包括:['*.jar'],目录:'libs')androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {排除组:'com.android.support',模块:'support-annotations'})编译'com.android.support:appcompat-v7:25.1.0'testCompile 'junit:junit:4.12'编译文件('libs/dom4j-1.6.jar')编译文件('libs/poi-3.16-beta2.jar')编译文件('libs/poi-ooxml-3.16-beta2.jar')编译文件('libs/poi-ooxml-schemas-3.16-beta2.jar')编译文件('libs/xmlbeans-2.6.0.jar')编译'com.android.support:multidex:1.0.1'}
现在我有这个错误!
错误:任务:app:transformClassesWithJarMergingForDebug"的执行失败.
<块引用>
com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:org/apache/xmlbeans/xml/stream/Location.class
由于直接使用 Apache POI 中的库时会遇到各种问题,因此 Apache POI 目前无法在开箱即用的 Android 手机上运行.Android 对作为 jar 文件一部分的重复类更加严格,不幸的是 XmlBeans 在它的 jar 文件中有这样的重复类.
有两个项目试图在 Android 上使用 Apache POI:
- https://github.com/andruhon/android5xlsx(适用于 Android 5)和
https://github.com/andruhon/AndroidReadXLSX(适用于 Android 4),两者目前仍基于 Apache兴趣点 3.12 - https://github.com/centic9/poi-on-android/(对于Android 5,由我维护),可以更轻松地使用较新版本的POI重新编译,例如它目前使用 3.16-beta2
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'
}
and now i have this error!
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/apache/xmlbeans/xml/stream/Location.class
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.
There are two projects that try to make it possible to use Apache POI on Android:
- 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屋!