首页 > 解决方案 > com.android.builder.dexing.DexArchiveBuilderException:处理失败。

问题描述

该应用程序在 minSdkVersion 24 上运行良好,但在将其减少到 minSdkVersion 19 后,我几乎没有遇到错误。在我的设备上运行它,但在 gradle 同步时没有错误。错误日志已发布。依赖项在 minSdkVersion 24 中运行良好,但在 minSdkVersion 19 中不适用,给我下面列出的错误,我需要它在 minSdkVersion 19 等较低版本上工作。任何帮助将不胜感激。

此处的错误日志:4 个错误,1 个警告

Calculate task graph    122ms
Run tasks   2m 7s 746ms null    
Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.  
com.android.builder.dexing.DexArchiveBuilderException: Failed to process C:\Users\hp\.gradle\caches\modules-2\files-2.1\android.arch.lifecycle\common-java8\1.1.1\795d68cd761d093ccb235d1d91b8fd17c2ae25ff\common-java8-1.1.1.jar   
com.android.builder.dexing.DexArchiveBuilderException: Error while dexing.  
com.android.tools.r8.CompilationFailedException: Compilation failed to complete 
com.android.tools.r8.utils.AbortException   
null    
Default interface methods are only supported starting with Android N (--min-api 24): void android.arch.lifecycle.DefaultLifecycleObserver.onCreate(android.arch.lifecycle.LifecycleOwner)   

我的应用级 gradle 文件。(此处为 minSdkversion 24)

 apply plugin: 'com.android.application'

android {
compileSdkVersion 27
defaultConfig {
    applicationId "com.example.hp.mkchat"
    minSdkVersion 24
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
    multiDexEnabled true
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.google.firebase:firebase-core:11.4.2'
implementation 'com.google.firebase:firebase-auth:11.4.2'
implementation 'com.android.support:support-v4:27.1.1-beta1'
implementation 'com.google.firebase:firebase-database:11.4.2'
implementation 'com.google.firebase:firebase-storage:11.4.2'
implementation 'com.google.firebase:firebase-messaging:11.4.2'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.android.support:multidex:1.0.1'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.squareup.okhttp:okhttp:2.5.0'
implementation 'com.firebaseui:firebase-ui-database:3.1.0'
implementation 'id.zelory:compressor:2.1.0'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.6.+'
// ViewModel and LiveData
implementation "android.arch.lifecycle:extensions:1.1.1"
// alternatively - just ViewModel
implementation "android.arch.lifecycle:viewmodel:1.1.1" // use -ktx for Kotlin
// alternatively - just LiveData
implementation "android.arch.lifecycle:livedata:1.1.1"
// alternatively - Lifecycles only (no ViewModel or LiveData).
//     Support library depends on this lightweight import
implementation "android.arch.lifecycle:runtime:1.1.1"
annotationProcessor "android.arch.lifecycle:compiler:1.1.1"
// alternately - if using Java8, use the following instead of compiler
implementation "android.arch.lifecycle:common-java8:1.1.1"
// optional - ReactiveStreams support for LiveData
implementation "android.arch.lifecycle:reactivestreams:1.1.1"
// optional - Test helpers for LiveData
testImplementation "android.arch.core:core-testing:1.1.1"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:0.5'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2'
}

apply plugin: 'com.google.gms.google-services'

标签: androidgradleandroid-gradle-pluginbuild.gradle

解决方案


android {
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

}

推荐阅读