com.android.builder.dexing.DexArchiveMergerException:无法在运行时合并dex异常

时间:2017-12-27 12:36:18

标签: android

错误:任务执行失败':app:transformDexArchiveWithExternalLibsDexMergerForDevDebug'。

  

java.lang.RuntimeException:com.android.builder.dexing.DexArchiveMergerException:无法合并dex

的build.gradle

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'

android {

    compileSdkVersion 27
    buildToolsVersion project.buildToolVersion
    dataBinding {
        enabled = true
    }


    productFlavors {

        dev {
            applicationIdSuffix ".dev"
            buildConfigField 'String', 'HOST', '"https://raconfiguratorqa.symx.com"'
            resValue 'string', 'google_maps_key', "AIzaSyDqXirXTahZHrKeSW62kmY3236S1Cqu4c4"

        }

        production {

            buildConfigField 'String', 'HOST', '"https://raconfiguratorqa.symx.com"'
            resValue 'string', 'google_maps_key', "AIzaSyDqXirXTahZHrKeSW62kmY3236S1Cqu4c4"

        }
    }

    signingConfigs {
        config {
            keyAlias 'contsynckey'
            keyPassword 'techjinikd'
            storeFile file('../KeyStore/contsynckey.jks')
            storePassword 'techjinikd'
        }
    }

    defaultConfig {
        applicationId "com.kdcos.contsync"
        minSdkVersion project.minSDKVersion
        targetSdkVersion project.targetSDKVersion
        versionCode 1
        versionName "1.0"
        vectorDrawables.useSupportLibrary = true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        flavorDimensions "versionCode" // This we had to put for Android Studio 3.0
        multiDexEnabled true
    }


}

dependencies {
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation "com.google.firebase:firebase-crash:$project.firebaseVersion"
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile("com.android.support.test.espresso:espresso-core:$project.espressoCoreVersion", {
        exclude group: 'com.android.support', module: 'support-annotations'
    })


    //support libraries
    compile "com.android.support:appcompat-v7:$project.supportLibraryVersion"
    compile "com.android.support:design:$project.supportLibraryVersion"
    compile "com.android.support:support-v4:$project.supportLibraryVersion"
    compile "com.android.support.constraint:constraint-layout:$project.constraintLayoutVersion"
    compile "com.android.support:cardview-v7:$project.supportLibraryVersion"



    // for generateQrCode 3.2.1

    compile "com.google.zxing:core:$project.qrCodeVersion"
}

repositories {
    mavenCentral()
}

apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.google.gms.google-services'

应用程序的bildgradle

buildscript {
    ext.kotlin_version = '1.2.0'
    ext.android_plugin_version='3.0.0-alpha5'
    ext.couchbase_version='1.4.1'
    repositories {
        jcenter()

        google()

        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.google.gms:google-services:3.0.0'
    }
}


project.ext {

    supportLibraryVersion = '27.0.2'
    buildToolVersion = '26.0.2'
    playServicesVersion = '11.6.2'
    firebaseVersion = '11.6.2'
    retrofitVersion = '2.3.0'
    compileSDKVersion = 26
    targetSDKVersion = 26
    minSDKVersion = 18
    gsonVersion=2.7
    rxAndroidVersion='2.0.1'
    rxJavaVersion='2.0.2'
    constraintLayoutVersion='1.0.2'
    junitVersion='4.12'
    espressoCoreVersion='2.2.2'
    lifecycleVersion='1.0.0-rc1'
    ottoVersion='1.3.8'
    daggerVersion='2.12'
    glideVersion = '4.2.0'
    archRoomVersion = "1.0.0"
    loggingVersion='3.8.0'
    qrCodeVersion='3.2.1'
}


allprojects {
    repositories {
        jcenter()
        maven { url 'https://maven.google.com' }

        google()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

请看我的build.gradle文件我总是得到干净后建立运行时给出异常甚至我已经重新启动android工作室并重新启动android系统并重新打开然后尝试运行应用程序然后我也得到相同的异常请建议我,我做错了什么。

1 个答案:

答案 0 :(得分:-1)

当我收到此错误时,我会执行以下操作。

  1. 从我的手机/模拟器中卸载版本并重新安装
  2. 如果这不起作用,通常是gradle依赖项的问题。您可能会有不一致的版本,例如testdata <- tibble::tibble(col1 = runif(1000), col2 = as.character(runif(1000)), col3 = as.character(runif(1000))) (这些只是示例)。如果有警告,请检查build.gradle文件