2

I'm developing an Android App in Android Studio with Java Coding. In this app when user clicks a button an excel file gets saved in external storage with some data.

For this I'm using Apache POI 4.1.0. I have added this in dependencies, but when I run the app error is coming as below

Error: MethodHandle.invoke and MethodHandle.invokeExact are only supported starting with Android O (--min-api 26)

android {    

    compileSdkVersion 27
    defaultConfig {
    applicationId "xxxxxxx"
    minSdkVersion 23
    targetSdkVersion 27
    versionCode 4
    versionName "1.0.3"
    testInstrumentationRunner 
    "android.support.test.runner.AndroidJUnitRunner"
    signingConfig signingConfigs.config
}
    buildTypes {
      release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
compileOptions {
    sourceCompatibility = 1.8
    targetCompatibility = 1.8
}
dependencies {    
    implementation 'org.apache.poi:poi:4.1.0'
    implementation 'org.apache.poi:poi-ooxml:4.1.0'
}
Sabir Syed
  • 422
  • 3
  • 19

2 Answers2

4

I was having the same problem, after reading this article I downloaded a previous version (specifically version poi-bin-4.0.1-20181203.zip ) from here and now it´s working. I hope this helps anyone having the same issue.

Fran Tardencilla
  • 289
  • 1
  • 2
  • 13
1

Finally I got the solution for my issue. Instead of using Apache POI, I used FileWriter for CSV format. Below is the reference for this.

https://stackabuse.com/reading-and-writing-csvs-in-java/

Sabir Syed
  • 422
  • 3
  • 19