首页 > 解决方案 > 合并 dex 档案时构建 APK 错误时出现错误

问题描述

以下是我的 gradle 文件:我已经清理了我的项目,重建了我的项目。它运行成功,但在构建 APK 时出错。

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId 'com.shipping.customerapp'
        minSdkVersion 16
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        testApplicationId 'shipping1'
    }
    dexOptions {
        javaMaxHeapSize "4g"
        preDexLibraries = false
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    testImplementation 'junit:junit:4.12'
    implementation 'com.shuhart.stickyheader:stickyheader:1.0.5'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'com.android.support:cardview-v7:28.0.0'
    implementation 'de.hdodenhof:circleimageview:2.1.0'
    implementation 'com.squareup.retrofit2:converter-jackson:2.3.0'
    implementation 'com.squareup.retrofit2:retrofit:2.3.0'
    implementation 'com.squareup.okhttp3:logging-interceptor:3.4.1'
    implementation 'com.google.firebase:firebase-core:16.0.5'
    implementation 'com.google.firebase:firebase-messaging:17.3.4'
    implementation 'com.google.firebase:firebase-iid:17.0.4'
    implementation 'com.google.firebase:firebase-auth:16.1.0'
    implementation 'ch.acra:acra:4.5.0'
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.muditsen.multilevelrecyclerview:multilevelview:1.0.0'
    implementation 'com.google.android.gms:play-services-places:16.0.0'
    implementation 'com.google.android.libraries.places:places-compat:1.1.0'
    implementation 'com.google.android.gms:play-services-location:16.0.0'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}


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

已完成任何可能的解决方案,但仍然出现此错误,请帮助。

我得到的错误::

Caused by: java.lang.RuntimeException: com.android.build.api.transform.TransformException: Error while generating the main dex list:
Error while merging dex archives: 

标签: androidbuild.gradle

解决方案


推荐阅读