Android Studio 3.0 无法合并dex [英] Android Studio 3.0 Unable to merge dex

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

问题描述

刚刚将 android studio 从 2.3.3 更新到 3.0 现在我遇到了错误

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

这是我的 gradle 文件:

应用插件:'com.android.application'安卓 {compileSdkVersion 25buildToolsVersion '26.0.2'默认配置{applicationId "d91.compassacademy"minSdk 版本 19目标SDK版本25版本代码 3版本名称1.0"testInstrumentationRunnerandroid.support.test.runner.AndroidJUnitRunner"vectorDrawables.useSupportLibrary = true}构建类型{释放 {minifyEnabled falseproguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'}调试{可调试真}}}存储库{MavenCentral()谷歌()}依赖{编译文件树(包括:['*.jar'],目录:'libs')编译'com.android.support:multidex:1.0.2'编译('com.google.api-client:google-api-client-android:1.22.0'){排除组:'org.apache.httpcomponents'}编译'pub.devrel:easypermissions:0.2.1'编译项目(路径:':mapviewpager')androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2',{排除组:'com.android.support',模块:'support-annotations'})编译'com.android.support:appcompat-v7:25.4.0'编译'com.android.support:recyclerview-v7:25.4.0'编译'com.android.support:cardview-v7:25.4.0'编译 'com.google.firebase:firebase-database:11.4.2'编译'com.google.android.gms:play-services-auth:11.4.2'编译 'com.google.android.gms:play-services-places:11.4.2'编译'com.google.android.gms:play-services:11.4.2'编译 'com.google.firebase:firebase-storage:11.4.2'编译 'com.google.firebase:firebase-auth:11.4.2'编译 'com.firebaseui:firebase-ui-database:1.1.1'编译'com.squareup.picasso:picasso:2.5.2'编译'com.theartofdev.edmodo:android-image-cropper:2.3.1'编译 'com.roughike:bottom-bar:2.1.1'编译'com.android.support:support-v4:25.4.0'编译'com.squareup.retrofit:retrofit:1.9.0'编译'com.android.support:support-vector-drawable:25.4.0'编译'pub.devrel:easypermissions:0.2.1'编译'com.google.code.findbugs:jsr305:2.0.1'编译'com.jakewharton:butterknife:8.4.0'编译 'com.getbase:floatingactionbutton:1.10.1'编译'com.android.support:multidex:1.0.2'编译'com.android.support.constraint:constraint-layout:1.1.0-beta3'testCompile 'junit:junit:4.12'}应用插件:'com.google.gms.google-services'

解决方案

我抬头:

错误:任务':memDicez:transformDexArchiveWithExternalLibsDexMergerForDebug'的执行失败.

<块引用>

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

昨天发现没什么用,

我的问题现在解决了,

这种方法可能会让您找到解决方案(它对我有用,但不保证对您有用)

我有:

android {compileSdkVersion 25buildToolsVersion '26.0.2'默认配置{applicationId "(我的秘密 applicationId)"minSdk 版本 21目标SDK版本25multiDexEnabled true}...}

依赖项{编译'com.android.support:appcompat-v7:25.3.1'编译'com.android.support:support-v4:25.3.1'编译 'ch.acra:acra:4.9.2'//编译'com.google.android.gms:play-services-auth:9.0.0'编译'com.loopj.android:android-async-http:1.4.9'编译'com.koushikdutta.ion:ion:2.+'编译组:'com.googlecode.json-simple',名称:'json-simple',版本:'1.1.1'}

当我改变时:

 minSdkVersion 21

 minSdkVersion 16

我收到了一条更具描述性的错误消息,确实通过 google/stack overflow 提供了解决方案.

就我而言

编译组:'com.googlecode.json-simple',名称:'json-simple',版本:'1.1.1'

应该改为

compile('com.googlecode.json-simple:json-simple:1.1.1') {排除组:'org.hamcrest',模块:'hamcrest-core'}

您可以稍后将 minSdkVersion 改回更高的值,但减少它似乎会提供更具描述性(或更可搜索)的问题(和解决方案)

干杯,

S.

Just Updated android studio from 2.3.3 to 3.0 now I am having the error

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

Here is my gradle file:

apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion '26.0.2'
defaultConfig {
    applicationId "d91.compassacademy"
    minSdkVersion 19
    targetSdkVersion 25
    versionCode 3
    versionName "1.0"

    testInstrumentationRunner 
"android.support.test.runner.AndroidJUnitRunner"
    vectorDrawables.useSupportLibrary = true
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
    debug {
        debuggable true
    }
}
}

repositories {
    mavenCentral()
    google()
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:multidex:1.0.2'

compile('com.google.api-client:google-api-client-android:1.22.0') {
    exclude group: 'org.apache.httpcomponents'
}
compile 'pub.devrel:easypermissions:0.2.1'
compile project(path: ':mapviewpager')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', 
{
    exclude group: 'com.android.support', module: 'support-annotations'

})
compile 'com.android.support:appcompat-v7:25.4.0'
compile 'com.android.support:recyclerview-v7:25.4.0'
compile 'com.android.support:cardview-v7:25.4.0'
compile 'com.google.firebase:firebase-database:11.4.2'
compile 'com.google.android.gms:play-services-auth:11.4.2'
compile 'com.google.android.gms:play-services-places:11.4.2'
compile 'com.google.android.gms:play-services:11.4.2'
compile 'com.google.firebase:firebase-storage:11.4.2'
compile 'com.google.firebase:firebase-auth:11.4.2'
compile 'com.firebaseui:firebase-ui-database:1.1.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.theartofdev.edmodo:android-image-cropper:2.3.1'
compile 'com.roughike:bottom-bar:2.1.1'
compile 'com.android.support:support-v4:25.4.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.android.support:support-vector-drawable:25.4.0'
compile 'pub.devrel:easypermissions:0.2.1'
compile 'com.google.code.findbugs:jsr305:2.0.1'
compile 'com.jakewharton:butterknife:8.4.0'
compile 'com.getbase:floatingactionbutton:1.10.1'
compile 'com.android.support:multidex:1.0.2'
compile 'com.android.support.constraint:constraint-layout:1.1.0-beta3'
testCompile 'junit:junit:4.12'
}


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

解决方案

I looked up:

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

com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

yesterday and found nothing usefull,

my issue is now solved,

this method might get you towards a solution (it worked for me, no guarantee it works for you)

I had:

android {
    compileSdkVersion 25
    buildToolsVersion '26.0.2'

    defaultConfig {
        applicationId "(my secret applicationId)"
        minSdkVersion 21
        targetSdkVersion 25
        multiDexEnabled true
    }

    ...

}

and

dependencies {
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:support-v4:25.3.1'
    compile 'ch.acra:acra:4.9.2'
    //compile 'com.google.android.gms:play-services-auth:9.0.0'
    compile 'com.loopj.android:android-async-http:1.4.9'
    compile 'com.koushikdutta.ion:ion:2.+'
    compile group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1.1'
}

and when I changed:

        minSdkVersion 21

to

        minSdkVersion 16

I got a more descriptive error message which did give solutions via google/stack overflow.

in my case

compile group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1.1'

should be changed to

compile('com.googlecode.json-simple:json-simple:1.1.1') {
    exclude group: 'org.hamcrest', module: 'hamcrest-core'
}

You can change the minSdkVersion back to a higher value later on but decreasing it seems to give a more descriptive (or more googleable) problem (and solution)

cheers,

S.

这篇关于Android Studio 3.0 无法合并dex的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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