简体   繁体   English

将Apache POI添加为外部库后,应用程序立即崩溃

[英]Application Crashes Immediately after adding Apache POI as External Libraries

I'm writing an application that utilizes Apache poi as external libraries so that I am able to generate excel files using data generated on the app. 我正在编写一个将Apache poi用作外部库的应用程序,以便能够使用在该应用程序上生成的数据生成excel文件。 However, after adding the apache jars to my lib folder and implementing them on my app build.gradle, I receive various DexArchiveBuilderExceptions. 但是,将apache jar添加到我的lib文件夹并在我的应用程序build.gradle上实现它们之后,我收到各种DexArchiveBuilderExceptions。

I've attempted to invalidate my caches and restart, as well as set my project to source compatibility Java_1_8; 我试图使缓存无效并重新启动,并将项目设置为与Java_1_8源代码兼容。 however, I still receive the same errors. 但是,我仍然收到相同的错误。

android {
    compileSdkVersion 28
    buildToolsVersion "29.0.0"

    defaultConfig {
        applicationId "com.example.statstopwatch"
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

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


dependencies {
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.jjoe64:graphview:4.2.2'
    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'
    implementation files('libs/poi-4.1.0.jar')
    implementation files('libs/poi-examples-4.1.0.jar')
    implementation files('libs/poi-excelant-4.1.0.jar')
    implementation files('libs/poi-ooxml-4.1.0.jar')
    implementation files('libs/poi-ooxml-schemas-4.1.0.jar')
    implementation files('libs/poi-scratchpad-4.1.0.jar')
}


I added these external libraries by pasting them into the libs folder and adding them as libraries, is this perhaps the cause of the error? 我通过将这些外部库粘贴到libs文件夹中并将它们添加为库来添加这些外部库,这可能是导致错误的原因吗?

You need to raise your minSdkVersion to 26, as those libraries are using things from Java 8 that are only available on Android 8.0 and higher. 您需要将minSdkVersion提高到26,因为这些库使用的是Java 8中的功能,这些功能仅在Android 8.0及更高版本上可用。

Or, find a version of those libraries that either are older or are designed for Android, that might allow you to keep your current minSdkVersion . 或者,找到这些库的一个较旧版本或为Android设计的版本,该版本可能允许您保留当前的minSdkVersion

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM