Error: Execution failed for task ': app: transformDexArchiveWithExternalLibsDexMergerForDebug'

1

Today I want to generate my APK and trying to do it I find this error:

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

java.lang.RuntimeException: java.lang.RuntimeException:    com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

This error does not allow me to advance, When I emulate my project it runs in the emulator without problem, then I did a Clean project and it seemed that it was going well, this error also appears when I give Rebuild Project, I am trying to generate the APK using Build > Build APKs. Next I show my build.gradle file, I appreciate your help.

apply plugin: 'com.android.application'

android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
    applicationId "com.tecnologias.uniagustapp"
    minSdkVersion 21
    targetSdkVersion 26
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner 
 "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 
'proguard-rules.pro'
    }
  }
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', 
{
    exclude group: 'com.android.support', module: 'support-annotations'
  })

compile 'com.google.dagger:dagger:2.0'
annotationProcessor 'com.google.dagger:dagger-compiler:2.0'
//noinspection GradleCompatible
compile 'com.android.support:design:26.+'
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support:support-v4:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:recyclerview-v7:26.+'
compile 'com.android.support:cardview-v7:26.+'
compile 'com.jakewharton:butterknife:8.4.0'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.google.android.gms:play-services:11.0.4'
compile 'com.google.android.gms:play-services-maps:11.0.4'
testCompile 'junit:junit:4.12'
}
    
asked by Ivan Alfredo 07.11.2017 в 17:44
source

1 answer

3

Try adding your Gradle :

android {
    defaultConfig {
       multiDexEnabled true
    }
}

What is this?

  

Android applications by default have   compatibility with SingleDex, which limits its application to have   only 65536 methods (references). Then multidexEnabled = true   it simply means that you can now write more than 65536 methods   (references) in your application.

More information here in case you are interested in understanding more.

    
answered by 07.11.2017 / 21:23
source