Antonín Kříž Antonín Kříž - 6 months ago 271
Java Question

Apache POI .xlsx reading, Gradle won't build

I have simple app to read cells from Excel file (2007, .xlsx).

I am using https://github.com/andruhon/android5xlsx libraries.

I am getting this error when building: http://pastebin.com/80jHfEVT (it's too long)

You can download my project if you need from here: https://mega.nz/#!2xwwAAJA!vwr_I7iL_htvem_R5tuZYfcT21xhrg2z2zhMJLzmq8Y with password "stackoverflow" (without "").

Source is same like here: java.exe finished with non-zero exit value 1 (my question), but I am using this gradle now:

Gradle.build

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}

dexOptions {
preDexLibraries false
//incremental true
javaMaxHeapSize "4g"
}

afterEvaluate {
tasks.matching {
it.name.startsWith('dex')
}.each { dx ->
if (dx.additionalParameters == null) {
dx.additionalParameters = ['--multi-dex']
} else {
dx.additionalParameters += '--multi-dex'
}
}
}

packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
}

defaultConfig {
applicationId "tona_kriz.kriziksupl"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"

multiDexEnabled true
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

//project.tasks.withType(com.android.build.gradle.tasks.Dex) {
// additionalParameters=['--core-library'] // --core-library option needed for now, will fix it soon
//}
}

dependencies {
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:multidex:1.0.1'
compile files('libs/poi-3.12-android.jar')
compile files('libs/poi-ooxml-schemas-3.12-20150511.jar')
}


Any solutions for me?

Answer

Ok, I found it! I need to use core-library in gradle.build.

project.tasks.withType(com.android.build.gradle.tasks.Dex) {
        additionalParameters=['--core-library'] // --core-library option needed for now, will fix it soon
    }

(source: https://github.com/andruhon/android5xlsx/blob/master/build.gradle )

EDIT: Or use library with changed javax to something else (etc aavax)

Comments