java.lang.RuntimeException:com.android.builder.dexing.DexArchiveMergerException:无法在Android Studio 3.0中合并dex [英] java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex in Android Studio 3.0

查看:4373
本文介绍了java.lang.RuntimeException:com.android.builder.dexing.DexArchiveMergerException:无法在Android Studio 3.0中合并dex的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的gradle文件:

  apply plugin:'com.android.application'

android {
compileSdkVersion 26
buildToolsVersion '27 .0.0'
useLibrary'org.apache.http.legacy'
defaultConfig {
multiDexEnabled true
applicationId 'com.example.test'
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName1.0
testInstrumentationRunnerandroid.support.test.runner.AndroidJUnitRunner


compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

productFlavors {
}
dexOptions {
增量真正
}
}

依赖项{
编译'com.google.android.gms:play-services: 10.0.1'
compile'c​​om.android.support:appcompat-v7:26.+'
编译'com.android.support:multidex:1.0.1'
编译'com.android.support.constraint:constraint-layout:1.0.0-alpha7'
编译'commons-io:commons- io:1.3.2'
compile'c​​om.mcxiaoke.volley:library:1.0.19'
compile'c​​om.facebook.stetho:stetho:1.5.0'
compile'c​​om。 github.PhilJay:MPAndroidChart:v3.0.2'
}

我得到的ocmplete错误编译该项目是:
$ b

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


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


完成错误如下:

pre $ 执行任务:[:app:assembleDebug]

AGPBI:{ kind:warning,text:android.dexOptions.incremental`属性已被弃用,它对构建pro没有任何影响cess。,sources:[{},{}]}
在项目':app'中配置'compile'已弃用。改为使用实施。
:app:buildInfoDebugLoader
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:checkDebugManifest UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:prepareLintJar UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:createDebugCompatibleScreenManifests UP-TO- DATE
:app:processDebugManifest UP-TO-DATE
:app:splitsDiscoveryTaskDebug UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources
:app:javaPreCompileDebug UP-TO-DATE
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:mergeDebugShaders UP-TO-DATE
:app:compileDebugShaders UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:packageInstantRunResourcesDebug UP-TO-DATE
:app:checkManifestChangesDebug
:app:ext ractTryWithResourcesSupportJarDebug最新日期
:app:transformClassesWithStackFramesFixerForDebug最新日期
:app:transformClassesWithDesugarForDebug最新日期
:app:transformClassesWithExtractJarsForDebug最新日期
: app:transformClassesWithInstantRunVerifierForDebug UP-TO-DATE
:app:transformClassesWithDependencyCheckerForDebug UP-TO-DATE
:app:compileDebugNdk NO-SOURCE
:app:mergeDebugJniLibFolders UP-TO-DATE
: app:transformNativeLibsWithMergeJniLibsForDebug UP-TO-DATE
:app:processDebugJavaRes NO-SOURCE
:app:transformResourcesWithMergeJavaResForDebug UP-TO-DATE
:app:transformNativeLibsAndResourcesWithJavaResourcesVerifierForDebug UP-TO-DATE
: app:transformClassesWithInstantRunForDebug UP-TO-DATE
:app:transformClassesEnhancedWithInstantReloadDexForDebug UP-TO-DATE
:app:incrementalDebugTasks UP-TO-DATE
:app:preColdswapDebug
:app:fastDeployDebugExtractor UP-TO-DATE
:app:generateDebugInstantRunAppInfo UP-TO-D ATE
:app:transformClassesWithInstantRunSlicerForDebug UP-TO-DATE
:app:transformClassesWithDexBuilderForDebug UP-TO-DATE
:app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED
:app:buildInfoGeneratorDebug

FAILURE:构建失败,出现异常。

*出错:
任务':app:transformDexArchiveWithExternalLibsDexMergerForDebug'的执行失败。
> java.lang.RuntimeException:com.android.builder.dexing.DexArchiveMergerException:无法合并dex

*尝试:
使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获取更多日志输出。

*在https://help.gradle.org获得更多帮助

2s内失败

39个可执行任务:5个已执行任务,34个最新的


解决方案

通过<$ c启用Multidex $ c> build.gradle 您的应用程序模块

  multiDexEnabled true 

不解决我的问题。 :(



试试这个:


  1. Build 菜单 - >按下 Clean Project 按钮。

  2. 完成任务后,请按 Build 菜单中的重建项目按钮。






compile is 现已弃用,所以最好使用实现 api


This is my gradle file:

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion '27.0.0'
    useLibrary 'org.apache.http.legacy'
    defaultConfig {
        multiDexEnabled true
        applicationId 'com.example.test'
        minSdkVersion 16
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    productFlavors {
    }
    dexOptions {
        incremental true
    }
}

dependencies {
    compile 'com.google.android.gms:play-services:10.0.1'
    compile 'com.android.support:appcompat-v7:26.+'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha7'
    compile 'commons-io:commons-io:1.3.2'
    compile 'com.mcxiaoke.volley:library:1.0.19'
    compile 'com.facebook.stetho:stetho:1.5.0'
    compile 'com.github.PhilJay:MPAndroidChart:v3.0.2'
}

The ocmplete error I get when compiling the project is:

Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.

java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

The complete error is as follows:

    Executing tasks: [:app:assembleDebug]

AGPBI: {"kind":"warning","text":"The `android.dexOptions.incremental` property is deprecated and it has no effect on the build process.","sources":[{},{}]}
Configuration 'compile' in project ':app' is deprecated. Use 'implementation' instead.
:app:buildInfoDebugLoader
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:checkDebugManifest UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:prepareLintJar UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:createDebugCompatibleScreenManifests UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:splitsDiscoveryTaskDebug UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources
:app:javaPreCompileDebug UP-TO-DATE
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:mergeDebugShaders UP-TO-DATE
:app:compileDebugShaders UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:packageInstantRunResourcesDebug UP-TO-DATE
:app:checkManifestChangesDebug
:app:extractTryWithResourcesSupportJarDebug UP-TO-DATE
:app:transformClassesWithStackFramesFixerForDebug UP-TO-DATE
:app:transformClassesWithDesugarForDebug UP-TO-DATE
:app:transformClassesWithExtractJarsForDebug UP-TO-DATE
:app:transformClassesWithInstantRunVerifierForDebug UP-TO-DATE
:app:transformClassesWithDependencyCheckerForDebug UP-TO-DATE
:app:compileDebugNdk NO-SOURCE
:app:mergeDebugJniLibFolders UP-TO-DATE
:app:transformNativeLibsWithMergeJniLibsForDebug UP-TO-DATE
:app:processDebugJavaRes NO-SOURCE
:app:transformResourcesWithMergeJavaResForDebug UP-TO-DATE
:app:transformNativeLibsAndResourcesWithJavaResourcesVerifierForDebug UP-TO-DATE
:app:transformClassesWithInstantRunForDebug UP-TO-DATE
:app:transformClassesEnhancedWithInstantReloadDexForDebug UP-TO-DATE
:app:incrementalDebugTasks UP-TO-DATE
:app:preColdswapDebug
:app:fastDeployDebugExtractor UP-TO-DATE
:app:generateDebugInstantRunAppInfo UP-TO-DATE
:app:transformClassesWithInstantRunSlicerForDebug UP-TO-DATE
:app:transformClassesWithDexBuilderForDebug UP-TO-DATE
:app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED
:app:buildInfoGeneratorDebug

FAILURE: Build failed with an exception.

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

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 2s

39 actionable tasks: 5 executed, 34 up-to-date

解决方案

Enable Multidex through build.gradle of your app module

multiDexEnabled true

Not Fix my problem. :(

Try this :

  1. From the Build menu -> press the Clean Project button.
  2. When task completed, press the Rebuild Project button from the Build menu.


compile is now deprecated so it's better to use implementation or api

这篇关于java.lang.RuntimeException:com.android.builder.dexing.DexArchiveMergerException:无法在Android Studio 3.0中合并dex的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆