How to fix Error: Program type already present: jxl.CellView when importing jxl.jar library

141 Views Asked by At

I added jxl.jar library in order to be able to write and read excel files. But when I run the program I get one of these errors:

Error: Program type already present: jxl.CellView
Error: Program type already present: jxl.Booleancell
Error: Program type already present: jxl.DateCell

Before I added the jxl library the code was working so the porblem is likely in the gradle. Before I used to get errors about different 'functions.properties' in the jxl.jar which I fixed by adding this

packagingOptions {

        exclude 'functions.properties'
        exclude 'functions_es.properties'
        exclude 'functions_nl.properties'
        exclude 'functions_en.properties'
        exclude 'functions_fr.properties'
        exclude 'functions_da.properties'
        exclude 'functions_de.properties'

    }

in Android {}, inside the gradle. I tried to do the same by adding

 exclude 'jxl/CellView'
 exclude 'jxl/BooleanCell'
 exclude 'jxl/dateCell'

inside the packagingOptions for the 'type already present' errors but it didn't work. How can I properly import this jxl library?

This is my entire gradle. Thanks in advance!

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.barxqrscanner2"
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    packagingOptions {

        exclude 'functions.properties'
        exclude 'functions_es.properties'
        exclude 'functions_nl.properties'
        exclude 'functions_en.properties'
        exclude 'functions_fr.properties'
        exclude 'functions_da.properties'
        exclude 'functions_de.properties'
        exclude 'jxl/CellView'
        exclude 'jxl/BooleanCell'
        exclude 'jxl/dateCell'
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation files('libs/opencsv-4.6.jar')
    implementation files('libs/jxl.jar')
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'com.google.code.gson:gson:2.8.2'
    implementation 'com.android.support:cardview-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.journeyapps:zxing-android-embedded:3.6.0'
    implementation 'com.google.zxing:core:3.3.0'
    implementation 'com.google.android.gms:play-services-auth:16.0.0'
    implementation 'net.sourceforge.jexcelapi:jxl:2.6.12'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
0

There are 0 best solutions below