Android Studio中的Apache POI库错误..?
问题描述:
我添加了5个jar文件的Apache POI,这样我就可以将文本保存为.docx文件,但是我无法首先运行该应用程序我现在有210级错误,现在我有这个错误有人可以帮助我..! ?我跟着这个例子 https://www.tutorialspoint.com/apache_poi_word/apache_poi_word_quick_guide.htmAndroid Studio中的Apache POI库错误..?
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:重复项:组织/阿帕奇/的xmlbeans/XML /流/ Location.class
答
com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复项:组织/阿帕奇/的xmlbeans/XML /流/ Location.class
这意味着你正在增加这个类两次或更多。
检查您所有的罐子文件将其删除。
答
由于您在直接使用Apache POI库时遇到的各种问题,当前的Apache POI将无法在您的Android Phone上使用。作为jar文件的一部分,Android对于重复类更加严格,不幸的是,XmlBeans在它的jar文件中有这样的重复类。
有迹象表明,试图使人们有可能在Android上使用Apache POI两个项目:
- 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-β2目前
是jar文件我该怎么检查它 – Eazyz
@Eazyz你可以打开一个Zip管理器的jar文件,并检查中的类例如 –
好,我会试着让你知道所以如果我在jar文件中找到2个位置类,我应该删除它们中的一个吗? – Eazyz