Android Studio 3.0 Execution failed for task: unable to merge dex

前端 未结 26 3320
野性不改
野性不改 2020-11-27 11:52

android studio was getting build error while build execution with following:

Error:Execution failed for task \':app:transformDexArchiveWithExternalLi

相关标签:
26条回答
  • 2020-11-27 11:53

    Are you in between SDK or platform updates? If yes complete those completely and then try to continue. I normally update the individual packages that need to be updated as to taking the entire update which could go up to 2.5 GB sometimes. Doing this complete update sometimes fails. I had a number of SDK updates once I upgraded to Android Studio 3.0 and was getting the above error since all packages had not been updated. Once I updated all packages the above error was gone.

    0 讨论(0)
  • 2020-11-27 11:54

    For Cordova based project, run cordova clean android before build again, as @mkimmet suggested.

    0 讨论(0)
  • 2020-11-27 11:56
    1)Please add multiDexEnabled true
    2)if you get compilation error then check your app level build.gradle weather same dependencies are implemented with different versions.
    3)Remove one if you find same dependencies.
    

    android { compileSdkVersion 28 defaultConfig {

        minSdkVersion 17
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    
    hope it works fine :) Happy Coding
    
    0 讨论(0)
  • 2020-11-27 11:58

    For me what fixed this error was changing one line in my app's gradle dependencies.

    from this:

    compile('com.google.android.gms:play-services-gcm:+') {
        force = true
    }
    

    To this:

    compile('com.google.android.gms:play-services-gcm:11.8.0') {
        force = true
    }
    
    0 讨论(0)
  • 2020-11-27 11:58

    For me, the problem was the use of Java 1.8 in a module, but not in the app module. I added this to the app build gradle and worked:

    android{
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }
    
    0 讨论(0)
  • 2020-11-27 11:58

    You can always revert to DX for now via this setting in your project's gradle.properties file:

    android.enableD8=false
    

    For more info, see https://android-developers.googleblog.com/2018/04/android-studio-switching-to-d8-dexer.html

    0 讨论(0)
提交回复
热议问题