【问题标题】:Caused by: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:原因:java.lang.RuntimeException:com.android.builder.dexing.DexArchiveMergerException:合并 dex 档案时出错:
【发布时间】:2018-04-10 15:22:45
【问题描述】:

我无法构建发布 APK。每次我得到 DexMergerException。 这是我的 build.gradles:

我正在使用 MVVM 结构。我有核心(核心的包名称与我的应用程序包相同)有我的库,我只在其中编写视图模型、模型和网络层。

我遇到的错误:

原因:com.android.builder.dexing.DexArchiveMergerException: 合并 dex 档案时出错:


原因:com.android.tools.r8.CompilationFailedException:编译失败


原因:com.android.tools.r8.utils.AbortException


节目类型已经存在:


app build.gradle:

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }
}


android {
    signingConfigs {
        debug {
            storeFile file(DEBUG_STORE_FILE)
        }

        release {
            storeFile file(RELEASE_STORE_FILE)
            storePassword RELEASE_STORE_PASSWORD
            keyAlias RELEASE_KEY_ALIAS
            keyPassword RELEASE_KEY_PASSWORD
            v2SigningEnabled false
        }

    }

    compileSdkVersion 27
    flavorDimensions "default"
    defaultConfig {
        applicationId "com.puma.one8crew"
        minSdkVersion 21
        targetSdkVersion 27
        vectorDrawables.useSupportLibrary = true
        versionCode 1
        multiDexEnabled true
        versionName "1.0"
        resValue 'string', 'facebook_app_id', FACEBOOK_APP_ID_DEV
        resValue 'string', 'fb_login_protocol_scheme', FACEBOOK_LOGIN_PROTOCOL_SCHEME
        manifestPlaceholders += [
                FACEBOOK_APP_ID_BGY: FACEBOOK_APP_ID_DEV,
                FB_LOGIN_SCHEME    : FACEBOOK_LOGIN_PROTOCOL_SCHEME
        ]
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    dataBinding {
        enabled = true
    }


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

    /* productFlavors {

        prod {
            resValue 'string', 'facebook_app_id', FACEBOOK_APP_ID_DEV
            resValue 'string', 'fb_login_protocol_scheme', FACEBOOK_LOGIN_PROTOCOL_SCHEME

        }

        stage {
            resValue 'string', 'facebook_app_id', FACEBOOK_APP_ID_DEV
            resValue 'string', 'fb_login_protocol_scheme', FACEBOOK_LOGIN_PROTOCOL_SCHEME
        }

    }*/

    applicationVariants.all { variant ->
        variant.outputs.all { output ->
            def project = "one8crew"
            outputFileName = "${project}_${variant.buildType.name}_${variant.versionName}.apk"
        }
    }

    dexOptions {
        javaMaxHeapSize "4g" //specify the heap size for the dex process
        preDexLibraries = true //delete the already predexed libraries
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation project(':core')
    implementation 'com.android.support:animated-vector-drawable:27.0.1'
    implementation 'com.android.support:customtabs:27.0.1'
    implementation 'com.android.support:cardview-v7:27.0.1'
    implementation 'com.android.support:appcompat-v7:27.0.1'

    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.facebook.android:facebook-android-sdk:4.31.0'
    implementation 'com.android.support:recyclerview-v7:27.0.1'
    implementation 'com.google.firebase:firebase-messaging:12.0.1'
    implementation 'com.google.android.gms:play-services-auth:12.0.1'

    implementation 'com.android.support:support-v4:27.0.1'
    implementation 'com.android.support:design:27.0.1'
    implementation 'com.android.support:support-v13:27.0.1'
    implementation 'com.alimuzaffar.lib:pinentryedittext:1.3.1'
    implementation 'de.hdodenhof:circleimageview:2.2.0'
    testImplementation 'junit:junit:4.12'

    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    //Dependencies for LifeCycle Android ViewModel
    implementation 'android.arch.lifecycle:extensions:1.1.1'
    implementation project(':com.wowza.gocoder.sdk')
    implementation 'com.skyfishjy.ripplebackground:library:1.0.1'

    //support design lib dependency fot tab
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation('com.crashlytics.sdk.android:crashlytics:2.9.1@aar') {
        transitive = true;
    }
}

下面是我的核心 build.gradle,我还为所有 lib 更新了相同的版本。

核心 build.gradle:

    apply plugin: 'com.android.library'

android {
    compileSdkVersion 27

    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

    }

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


    dataBinding {
        enabled = true
    }
    repositories {
        flatDir {
            dirs 'libs'
        }
        jcenter()
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    compileOnly 'com.wowza.gocoder.sdk.android:com.wowza.gocoder.sdk:1.0b7@aar'
//    compile 'android.arch.lifecycle:extensions:1.1.1'
    implementation 'com.google.dagger:dagger:2.11'
    api('com.squareup.retrofit2:retrofit:2.1.0') {
        exclude module: 'okhttp'
    }
    api 'com.google.code.gson:gson:2.8.1'
    api 'com.squareup.retrofit2:converter-gson:2.3.0'
    api 'swarajsaaj:otpreader:1.1'
    api 'com.github.bumptech.glide:glide:4.3.0'
    annotationProcessor 'com.google.dagger:dagger-compiler:2.11'
    //Dependencies for LifeCycle Android ViewModel
    implementation 'android.arch.lifecycle:extensions:1.1.1'
//    annotationProcessor "android.arch.lifecycle:compiler:1.1.1"

    compileOnly project(':com.wowza.gocoder.sdk')
    compile project(':libraries:horizontalcalendar')
    compile project(':libraries:calendarview')

    //Library for setting fonts
    api 'uk.co.chrisjenx:calligraphy:2.3.0'

    implementation 'com.android.support:multidex:1.0.3'

}

我尝试了很多次,但我无法理解这个问题背后的原因。

【问题讨论】:

标签: android build android-multidex


【解决方案1】:

我今天也发生了同样的事情,这就是解决问题的方法:

找到com.google.android.gms:play-services的所有依赖。

它们现在都有不同的版本。只需将鼠标放在它们上并更正版本号(即,对我来说,是将地图从 15.0.0 升级到 15.0.2 并将标签管理器升级到 15.0.1)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-04-21
    • 1970-01-01
    • 2018-08-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多