user5330423
user5330423

Reputation:

Odd DexArchiveMergerException

I've encountered this issue in the past, and was able to fix it fairly easily. This time, however, I do not see what's causing it. The only change to the build.gradle I have made since it worked was implementation project(':sharedfiles') - a shared common module for wear/mobile. I didn't add this, I added the module as a dependency and this line was automatically added, so I doubt it is an error. I have multipleDexEnabled true and cannot find any conflicting dependencies. Any help would be appreciated, this is my first time using a common module. Here are the two build.gradle files.

Mobile Module

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "bhprograms.supremis"
        minSdkVersion 23
        targetSdkVersion 26
        multiDexEnabled true
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

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:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    wearApp project(':wear')
    implementation 'com.google.android.gms:play-services-wearable:+'
    implementation files('libs/gson.jar')
    implementation project(':sharedfiles')
}

The Common Module

apply plugin: 'com.android.library'

android {
    compileSdkVersion 26



    defaultConfig {
        minSdkVersion 23
        targetSdkVersion 26
        versionCode 1
        multiDexEnabled true
        minSdkVersion 23
        targetSdkVersion 26
        versionName "1.0"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation 'com.android.support:appcompat-v7:26.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    implementation files('libs/gson.jar')
}

And, of course, the error.

Error:Execution failed for task ':mobile:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

Upvotes: 0

Views: 51

Answers (1)

user5330423
user5330423

Reputation:

Solved by getting rid of implementation files('libs/gson.jar') in the mobile module. Not sure why this fixed it, likely because I was not using this jar anymore in the mobile module. Left it there as I may need it in the future if an experimental feature does not work, but this is what was causing the issue.

Upvotes: 1

Related Questions