2

当我编译我的应用程序时,我得到了以下错误,例如,

错误:任务执行失败

':app:transformDexArchiveWithExternalLibsDexMergerForDebug'。com.android.builder.dexing.DexArchiveMergerException:无法合并 dex

我在我的 app.build 文件中添加了 multiDexEnabled true 但仍然遇到同样的问题。我该如何解决这个错误。

在我的 app.build 文件下面

apply plugin: 'com.android.application'
 android {
compileSdkVersion 27
defaultConfig {
    applicationId "com.example.rutunjay.retrofit_example"
    minSdkVersion 21
    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'
    }
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}}

dependencies {

testImplementation 'junit:junit:4.12'
compile 'android.arch.lifecycle:runtime:1.0.0-alpha1'
compile 'android.arch.lifecycle:extensions:1.0.0-alpha1'
annotationProcessor "android.arch.lifecycle:compiler:1.0.0-alpha1"}
4

1 回答 1

2

使用 latest DependenciesLifecycle包括LiveDataViewModel

尝试这个

implementation 'android.arch.lifecycle:runtime:1.1.1'
implementation 'android.arch.lifecycle:extensions:1.1.1'
annotationProcessor "android.arch.lifecycle:compiler:1.1.1"

Clean-Rebuild- Run你的项目

于 2018-05-11T12:13:18.133 回答