• Register
0 votes
295 views

Problem :

My android studio was getting build error while build execution as following:

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

6 5 3
7,540 points

Please log in or register to answer this question.

2 Answers

0 votes

Solution :

There are many options to shut the warning off depending on the minSdkVersion, it is set below 20:

Update the code as below:

 android {
     defaultConfig {
         ...
         minSdkVersion 15 
         targetSdkVersion 26
         multiDexEnabled true
     }
     ... }
 dependencies {   compile 'com.android.support:multidex:1.0.3' }

If you have the minSdkVersion greater than 20 in your build.gradle set use the following to shut down the warning:

Update the code as below:

  android {
      defaultConfig {
          ...
          minSdkVersion 21 
          targetSdkVersion 26
          multiDexEnabled true
      }
      ... }

Update your dependencies as below:

     dependencies {
implementation 'com.android.support:multidex:1.0.3'
     }

Again the only difference is your keywords in dependencies as below:

If minSdkVersion below 20: use compile

If minSdkVersion above 20: use implementation

 

OR

If above solution is not working for you then try below solution it worked for me and resolved my issue :

Please add below code:

multiDexEnabled true

and also add below code:

packagingOptions {
        exclude 'META-INF/NOTICE' 
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/notice'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license'
        exclude 'META-INF/license.txt'
    }

in your app level Build.gradle file and it will solve your issue

9 7 4
38,600 points
0 votes

Solution:

This error occurs at the time you include an external library which may not be compatible with your compileSdkVersion .

Be sincere at the time you are including an external library.

1. Ensure that all your support libraries are similar as compileSdkVersion of your build.gradle(Module:app) in my case it is 26.

2. In your defaultConfig category type multiDexEnabled true. 

3. Go to File | Settings | Build, Execution, Deployment | Instant Run and attempt to Enable/Disable Instant Run to hot swap. and                 click okay

  • Sync Your project.

  • Lastly, Go to Build | click on Rebuild Project.

  • Note: Rebuild Project first cleans and then builds the project.

Attempt to include this in gradle

   android {
      defaultConfig {
        multiDexEnabled true
        }
   }

Refer to this link: As there are various options to closed the warning off relying on the minSdkVersion, it is set below 20:

 android {
     defaultConfig {
         ...
         minSdkVersion 15 
         targetSdkVersion 26
         multiDexEnabled true
     }
     ... }

 dependencies {   compile 'com.android.support:multidex:1.0.3' }

In case you have a minSdkVersion greater than 20 in your build.gradle set employ the following to shut down the warning:

android {
      defaultConfig {
          ...
          minSdkVersion 21 
          targetSdkVersion 26
          multiDexEnabled true
      }
      ... }

Update dependencies as follows:

 dependencies {
        implementation 'com.android.support:multidex:1.0.3'
     }

Again the only difference is the keywords in dependencies:

minSdkVersion below 20: use compile

minSdkVersion above 20: exercise implementation For me, adding

multiDexEnabled true

and

packagingOptions {
        exclude 'META-INF/NOTICE' 
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/notice'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license'
        exclude 'META-INF/license.txt'
    }

I attempted many solutions as mentioned above adding the multiDexEnabled true however none of that worked for me.

Here is the solution which performed for me - copy this code in app\build.gradle file

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support' && requested.name != 'multidex') {
            details.useVersion "${rootProject.ext.supportLibVersion}"
        }
    }
}

Employ multiDexEnabled true as below.

{
 minSdkVersion 17
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    multiDexEnabled true
}

and

implementation 'com.android.support:multidex:1.0.3'

 

10 6 4
31,120 points

Related questions

0 votes
1 answer 3 views
3 views
Problem: I have tried all of the solutions suggested and still not be able to fix the problem. Please help me with some advice.
asked Apr 1 zayed1 24.7k points
0 votes
1 answer 37 views
37 views
Problem: could not resolve com.android.support:appcompat-v7:26.1.0.
asked Feb 22 Dan phillip 4.1k points
0 votes
1 answer 105 views
105 views
Problem : I have the Android Studio Beta. I have created the new project with compiling my old modules but when I tried launching my app it did not launch and it gave me the below message: Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'. com ... merge dex But I am unable to know how to fix above error. I researched on this for hours but with no success.
asked Jan 31, 2020 jwilliam 3.9k points
0 votes
1 answer 119 views
119 views
Problem : I have updated my Android Studio to 3.0 but now facing the lot of issues.. So now stopped on the point with below issue: Could not resolve all files for configuration ':applib:_lintClassPath'. > Could not find com.android.tools.lint:lint-gradle:26.1.0-alpha01. ... project :applib I am currently using latest gradle version as: "gradle-4.2.1-all.zip". Does anyone know what my issue can be?
asked Dec 17, 2019 alecxe 7.5k points
0 votes
1 answer 644 views
644 views
Problem : Using new android studio with new 3.0.0 Gradle pluging. When building some warning occurred as follows: registerResGeneratingTask is deprecated, useregisterGeneratedFolders(FileCollection)
asked Nov 30, 2019 alecxe 7.5k points
0 votes
1 answer 2 views
2 views
Problem What should I do to solve this problem, "org.gradle.api.tasks.taskexecutionexception: execution failed for task :app:mergedebugresources?"
asked 3 days ago salim1 30.8k points
0 votes
1 answer 3 views
3 views
Problem: I'm having problems to execute ':app: transform classes with desugar for debug'. Can you help me?
asked Mar 31 zayed1 24.7k points
0 votes
1 answer 26 views
26 views
Problem: execution failed for task ':app:compiledebugjavawithjavac'
asked Feb 18 charles mathews 5.5k points
1 vote
1 answer 538 views
538 views
Problem : I am very beginner to Android and Firebase. I am taking help of tutorials to learn Android Programming. I am trying to add the Firebase-database to my Android application and I am facing below error: FAILURE: Build failed with an exception. ·         What went ... to get full insights. I am stuck with above Android error. Need some expert who can help me in fixing above Android error.
asked May 16, 2020 Martin K 6.6k points
0 votes
1 answer 43 views
43 views
Problem : I am new to Android Programming. I have started working on it recently. Now I am facing below error message. Error:Execution failed for task ':app:transformClassesWithDexForDebug'. com.android.build.transform.api.TransformException: com.android.ide.common. ... have added too many Gradle dependencies, but all those dependencies are important for my project. Have anybody faced this issue?
asked Feb 28, 2020 mphil 2.3k points