• Register
0 votes
181 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 76 views
76 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 91 views
91 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 251 views
251 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 34 views
34 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
0 votes
2 answers 869 views
869 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, 2020 jwilliam 3.9k points
0 votes
1 answer 462 views
462 views
Problem : I am facing the gradle error at the building from few days it just came randomly. My project depends on the multiple libraries and it built without the problems until few days (even with a libraries) ... .gradle.api.internal.changedetection.state.CacheLockReleasingTaskExecuter$1.run(CacheLockReleasingTaskExecuter.java:40) at org.gradle.internal.Factories$1.create(Factories.java:26)
asked Jan 30, 2020 jwilliam 3.9k points
0 votes
1 answer 547 views
547 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 502 views
502 views
Problem : Recently I have updated to Android Studio 3.1. But my project is not running anymore. I have searched for the solution all over the internet with zero positive results. Below is the error that I get in my Logcat: “Java.lang.noclassdeffounderror: ... sdk:4.+'     implementation 'com.parse:parsefacebookutils-v4-android:1.10.3@aar'     implementation 'com.commit451:PhotoView:1.2.4' }
asked Jan 30, 2020 jwilliam 3.9k points
0 votes
1 answer 9 views
9 views
I am trying to obtain the latitude and longitude value from the address using PHP.
asked Sep 25, 2020 Daniel Anderson 4k points