• Register
0 votes
119 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

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 54 views
54 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 jwilliam 3.9k points
0 votes
1 answer 82 views
82 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
1 vote
1 answer 120 views
120 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 Martin K 6.6k points
0 votes
1 answer 26 views
26 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 mphil 2.3k points
0 votes
2 answers 692 views
692 views
Problem : Currently I am using the Android Studio 2.1 but when I try to run it the suddenly my App shows me the below error Message my Gradle Build saying the following Exception is: org.gradle. ... .execute(SkipEmptySourceFilesTaskExec uter.java:52) at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.j ava:52)
asked Jan 31 jwilliam 3.9k points