【问题标题】:Unable to merge dex app:transformDexArchiveWithExternalLibsDexMergerForDebug无法合并 dex 应用程序:transformDexArchiveWithExternalLibsDexMergerForDebug
【发布时间】:2018-02-26 03:28:05
【问题描述】:

我能够清理和重建项目文件,但我无法运行应用程序,因为它引发了一个 RuntimeException。

这是我的错误:

Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

这是我的毕业典礼:

/*
 * Copyright © 2018 Quillbook. All rights reserved
 */

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.dumpcoders.danielcruise.quillbook"
        minSdkVersion 17
        multiDexEnabled true
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

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

}
packagingOptions {
    exclude 'AndroidManifest.xml'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/DEPENDENCIES'

}
dexOptions {

    jumboMode true
    javaMaxHeapSize "4g"

}
}
dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:27.0.2'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:design:27.0.2'
    implementation 'com.android.support:support-v4:27.0.2'
    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'
    implementation('com.amazonaws:aws-android-sdk-mobile-client:2.6.15@aar') { transitive = true }
    implementation 'com.amazonaws:aws-android-sdk-cognito:2.6.15'
    implementation 'com.amazonaws:aws-android-sdk-cognitoidentityprovider:2.6.15'
    implementation 'com.amazonaws:aws-android-sdk-core:2.6.15'
    implementation 'com.amazonaws:aws-android-sdk-ddb:2.6.15'
    implementation 'com.amazonaws:aws-android-sdk-mobileanalytics:2.6.15'
    implementation 'com.amazonaws:aws-android-sdk-s3:2.6.15'
    implementation 'com.amazonaws:aws-android-sdk-sns:2.6.15'
    implementation 'com.amazonaws:aws-android-sdk-sqs:2.6.15'
    api 'com.amazonaws:aws-android-sdk-apigateway-core:2.6.15'
}

我已经实现了我的项目所需的所有 AWS 库,我在这里要做的是连接到 AWS!

【问题讨论】:

  • 尝试从所有 aws 依赖项中排除组排除组:'commons-io',模块:'commons-io'`
  • 我排除了这个实现 ('com.amazonaws:aws-android-sdk-cognito:2.6.15'){exclude group:'commons-io',module:'commons-io'}是否正确??
  • 是的,没错。看看它是否有效。如果不是,请查看有关构建失败的详细消息。
  • 这行不通……
  • 您是否启用了multiDexEnabled?如果没有,则首先启用multiDex。我可以在您的 build.gradle 中看到它,但在 Application 类中对其进行了初始化?

标签: android amazon-web-services android-gradle-plugin


【解决方案1】:

更新: 尝试了您的 gradle 配置并完美运行。但问题的主要原因在于

dexOptions {
    jumboMode true
    javaMaxHeapSize "4g"
}

更多关于jumboMode

【讨论】:

  • 不适合我...在事件日志中它说:找不到来源:找不到'aws-android-sdk-apigateway-core-2.6.15.jar'的来源
  • Messages Gradle Build:错误:任务“:app:transformDexArchiveWithExternalLibsDexMergerForDebug”执行失败。 > java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: 无法合并 dex
  • 我尽我所能@tatocaster
  • 我尝试了相同的 gradle 配置,即使没有 multidex 并且可以正常工作。尝试使 Android Studio 缓存无效,然后重试。我尝试使用/不使用jumboMode,但效果相同,构建成功。
  • 是的! ..... 非常感谢它的工作原理......自从 8 小时以来,我一直在寻找解决方案。你救了我的一天! @tatocaster
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-06-21
  • 1970-01-01
  • 2018-02-26
  • 2018-05-26
  • 1970-01-01
相关资源
最近更新 更多