如何解决错误:程序类型已经存在:导入jxl.jar库时出现jxl.CellView

时间:2019-05-29 12:35:33

标签: android jxl

我添加了jxl.jar库,以便能够写入和读取excel文件。但是当我运行程序时,出现以下错误之一:

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

在我添加jxl库之前,代码已经正常工作,因此问题可能就在gradle中。 在我以前通过添加此

修复的jxl.jar中出现有关不同'functions.properties'的错误之前
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'

    }
在gradle内的Android {}

。我尝试通过添加

做同样的事情
 exclude 'jxl/CellView'
 exclude 'jxl/BooleanCell'
 exclude 'jxl/dateCell'

在PackagingOptions内出现“类型已存在”错误,但没有用。如何正确导入该jxl库?

这是我的全部。预先感谢!

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 个答案:

没有答案