1

I'm trying to build a mock-up of an app that accesses Spotify's public API and these are what I've needed to make the services and functions of the app work so far. The gradle sync itself is fine, however when I try to build the project I have this problem:

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

Things I have tried:

  1. Cleaning and rebuilding the project from the menu
  2. Enabling multidex in gradle

multiDexEnabled true
  1. Making sure the different dependencies aren't repeated inside the gradle

I'm running on Android Studio 3 on MacOS Sierra 10.12.6.

This is my gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion '26.0.2'

    defaultConfig {
        applicationId "com.example.mostags.trial5"
        minSdkVersion 25
        targetSdkVersion 26
        versionCode 1
        versionName "1.2"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    sourceSets {
        main {
            java.srcDirs = ['src/main/java', 'src/main/java/com.example.mostags.trial5/methods']
        }
    }
}

repositories {
    google()

    jcenter()
    mavenCentral()
    flatDir {
        dirs 'libs'
    }
    maven { url 'https://github.com/thelinmichael/spotify-web-api-java' }
}

android {
    configurations.all {
        resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
        resolutionStrategy.force 'com.google.android.gms:play-services:11.2.2'
    }
}


dependencies {
    compile 'com.android.support:multidex:1.0.2'
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.1', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    compile('com.jayway.jsonpath:json-path:2.0.0') {
        exclude group: 'net.minidev', module: 'asm'
    }

    implementation fileTree(dir: 'libs', include: ['*.jar'])
    testImplementation 'junit:junit:4.12'


    compile('com.amazonaws:aws-android-sdk-mobile-client:2.6.7@aar') { transitive = true; }
    compile('com.amazonaws:aws-android-sdk-auth-userpools:2.6.+@aar') { transitive = true; }
    compile('com.amazonaws:aws-android-sdk-auth-ui:2.6.+@aar') { transitive = true; }

    compile 'net.sf.json-lib:json-lib:2.4:jdk15'

    compile 'com.google.guava:guava:23.6-android'
    compile 'com.google.protobuf:protobuf-java:3.5.1'
    compile 'com.google.protobuf:protobuf-lite:3.0.1'
    compile 'com.google.protobuf:protobuf-gradle-plugin:0.8.3'

    compile('se.michaelthelin.spotify:spotify-web-api-java:1.5.0') {
        exclude group: "commons-beanutils", module: "commons-beanutils"

    }
    compile 'commons-beanutils:commons-beanutils:20030211.134440'
    compile 'commons-codec:commons-codec:1.11'

    compile 'org.apache.httpcomponents:httpcore:4.4.8'
    compile 'org.apache.httpcomponents:httpclient:4.5.4'

    android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true;

    compile fileTree(include: ['*.jar'], dir: 'libs')

    //these two lines are added
    compile 'com.squareup.retrofit2:retrofit:2.3.0'
    compile 'com.squareup.retrofit2:converter-gson:2.2.0'

    // This library handles authentication and authorization
    compile 'com.spotify.android:auth:1.0.0-alpha'

}
halfer
  • 19,824
  • 17
  • 99
  • 186
ssmost
  • 41
  • 8
  • Any possible solutions [in this question](https://stackoverflow.com/questions/46267621/unable-to-merge-dex)? – halfer Jan 18 '18 at 21:51

1 Answers1

0

Try this

multiDexEnabled = true
  • I've tried that and still have the same error, it was the first fix I tried but it didn't fix anything unfortunately. Thank you for the suggestion though. – ssmost Jan 18 '18 at 17:52