Failed to compile project with Excel library connected

半世苍凉 提交于 2019-12-24 18:42:21

问题


Trying to compile project with Excel libraries, for to read and write *.xls and *.xlsx files. Also I have imported com.android.support:multidex:1.0.3 library and set multiDexEnabled to true in default config. Libraries are the last 5 entries in my build.gradle dependencies:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    buildToolsVersion '28.0.3'
    defaultConfig {
        applicationId "com.hand.measurements"
        minSdkVersion 14
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        debug {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.google.code.gson:gson:2.8.0'
    implementation 'com.squareup.retrofit2:retrofit:2.1.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
    implementation 'org.apache.commons:commons-lang3:3.6'

    implementation 'junit:junit:4.12'
    implementation 'com.android.support.test:runner:1.0.2'
    implementation 'com.android.support.test.espresso:espresso-core:3.0.2'

    implementation project(':classification')
    implementation files('libs/commons-io-2.6.jar')
    implementation files('libs/poi-3.17.jar')
    implementation files('libs/poi-ooxml-3.17.jar')
    implementation files('libs/poi-ooxml-schemas-3.17.jar')
    implementation files('libs/commons-collections4-4.1.jar')
    implementation files('libs/xmlbeans-2.6.0.jar')
}

When I compile this project, following errors occur:

Information:Gradle tasks [build]
Error:Program type already present: org.apache.xmlbeans.xml.stream.XMLName
Error:Program type already present: org.apache.xmlbeans.xml.stream.Location
Error:com.android.builder.dexing.DexArchiveBuilderException: Failed to process C:\base_android\AndroidStudioProjects\Measurements\app\libs\xmlbeans-2.6.0.jar
Error:com.android.builder.dexing.DexArchiveBuilderException: Error while dexing.
Error:com.android.tools.r8.CompilationFailedException: Compilation failed to complete
Error:com.android.tools.r8.utils.AbortException: Error: Program type already present: org.apache.xmlbeans.xml.stream.XMLName
Information:BUILD FAILED in 6m 39s
Information:6 errors
Information:0 warnings
Information:See complete output in console

I tried to change xmlbeans library to 3.0.1 and 3.0.2 versions, project compiled successfully, but when it executed following line with *.xlsx document:

Workbook workbook = WorkbookFactory.create(is);

runtime error occured:

java.lang.NoClassDefFoundError: javax.xml.stream.XMLEventFactory

Also it throwed runtime error during new XSSFWorkbook(is) operator.

How can I fix it to be able to work with *.xlsx format?

来源:https://stackoverflow.com/questions/53805814/failed-to-compile-project-with-excel-library-connected

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!