2017-02-21 113 views
4

我添加了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

回答

0

com.android.build.api.transform.TransformException:java.util.zip.ZipException:重複項:組織/阿帕奇/的xmlbeans/XML /流/ Location.class

這意味着你正在增加這個類兩次或更多
檢查您所有的罐子文件將其刪除。

+0

是jar文件我該怎麼檢查它 – Eazyz

+0

@Eazyz你可以打開一個Zip管理器的jar文件,並檢查中的類例如 –

+0

好,我會試着讓你知道所以如果我在jar文件中找到2個位置類,我應該刪除它們中的一個嗎? – Eazyz

0

由於您在直接使用Apache POI庫時遇到的各種問題,當前的Apache POI將無法在您的Android Phone上使用。作爲jar文件的一部分,Android對於重複類更加嚴格,不幸的是,XmlBeans在它的jar文件中有這樣的重複類。

有跡象表明,試圖使人們有可能在Android上使用Apache POI兩個項目: