Getting error building App: app:transformDexArchiveWithDexMergerForDebug

Patzu picture Patzu · Oct 31, 2017 · Viewed 7.5k times · Source

I get the following error while building the app in android studio, why this is happening? Is it related to my proguard rules or dexguard rules?

when I add " multiDexEnabled true" in build.gradle file, I get below error:

Error:Execution failed for task ':app:transformDexArchiveWithDexMergerForDebug'.
> com.android.build.api.transform.TransformException: 
java.nio.file.NoSuchFileException: 
D:\android\app\build\intermediates\multi-dex\debug\maindexlist.txt

But, when I add " multiDexEnabled true" in build.gradle file, I get below error:

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

build.gradle

 buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
        flatDir { dirs 'D:/DexGuard-8.0.17/lib' }
    }
    dependencies {
        classpath 'io.fabric.tools:gradle:1.22.1'
        classpath ':dexguard:'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'dexguard'

repositories {
    maven { url 'https://maven.fabric.io/public' }
}

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.0"
    defaultConfig {
        applicationId "com.c.android"
        minSdkVersion 19
        targetSdkVersion 26
        multiDexEnabled true
    }
    buildTypes {
        debug {
            proguardFile 'D:/android/app/proguard-project.txt'
            proguardFile 'dexguard-project.txt'
        }
        release {
            proguardFile 'D:/android/app/proguard-project.txt'
            proguardFile 'dexguard-project.txt'
        }
    }
}
dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
        exclude group: 'com.google.code.findbugs'
    })
    compile 'org.greenrobot:eventbus:3.0.0'
    compile 'com.android.support:design:26.1.0'
    compile 'com.google.android.gms:play-services-base:11.4.2'
    compile 'com.google.android.gms:play-services-maps:11.4.2'
    compile 'com.google.android.gms:play-services-location:11.4.2'
    compile 'com.google.android.gms:play-services-places:11.4.2'
    compile 'com.android.support:support-v13:26.1.0'
    compile 'com.android.support:support-v4:26.1.0'
    compile 'com.android.support:cardview-v7:26.1.0'
    compile 'com.specyci:residemenu:1.6'
    compile 'com.basgeekball:awesome-validation:2.0'
    compile 'com.bahmanm:persianutils_2.10:1.0'
    compile 'com.fasterxml.jackson.core:jackson-databind:2.8.6'
    compile 'org.springframework.android:spring-android-rest-template:2.0.0.M3'
    compile('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') {
        transitive = true
    }
    compile 'com.google.guava:guava:23.3-android'
}

Answer

Sikander Bakht picture Sikander Bakht · Jul 18, 2019

Delete your build folder inside "app/"