首页 > 解决方案 > 使用 stanford corenlp 时出现 DexArchiveBuilderException 异常

问题描述

我正在尝试使用stanford corenlp对单词进行词形还原但是当我添加了如下依赖项时。

allprojects {
    repositories {
        maven { url 'https://jitpack.io' }
    }
}

android {
compileSdkVersion 27



defaultConfig {
    minSdkVersion 23
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"

    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

}

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

}


 dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
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'
compile 'ai.api:sdk:2.0.7@aar'
compile 'ai.api:libai:1.6.12'
compile 'com.android.support:appcompat-v7:27.1.1'
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
compile 'edu.stanford.nlp:stanford-corenlp:3.8.0'

 }
repositories {
mavenCentral()
}

当我运行我的应用程序时,它给了我以下异常:

错误:com.android.builder.dexing.DexArchiveBuilderException:无法处理 C:\Users\LPT-0096.gradle\caches\modules-2\files-2.1\edu.stanford.nlp\stanford-corenlp\3.8.0\ 79c0ba8dba9734bf51d898f4526117980f7c49c5\stanford-corenlp-3.8.0.jar 错误:com.android.builder.dexing.DexArchiveBuilderException: com.android.tools.r8.errors.CompilationError: 默认接口方法仅支持从 Android N (--min- api 24): void edu.stanford.nlp.pipeline.Annotator.unmount() Error:com.android.tools.r8.errors.CompilationError: 默认接口方法仅支持从 Android N (--min-api 24) 开始: void edu.stanford.nlp.pipeline.Annotator.unmount() 错误:任务“:ModroidApp:transformClassesWithDexBuilderForDebug”执行失败。com.android.build.api.transform.TransformException:com.android.builder.dexing。

请帮助我为什么每次运行我的应用程序时都会出现以下异常。

标签: javaandroidstanford-nlplemmatization

解决方案


Your stack trace output :

com.android.tools.r8.errors.CompilationError: Default interface methods are only supported starting with Android N (--min-api 24)

So you have to ugrade your minSdkVersion to 24

EDIT: Enabling java 8 compatibiliy solve the issue : adding the block below to build.gradle

compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

推荐阅读