0

me and my cooworkers are at the 1st experience with android programming and we are facing what we believe its a Bug and we cant solve it

Using Android Studio 3.0 when we try to build and run a project after the implementation of the google play services library we are given this error

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

we have simply followed the instruction at GoogleMaps Api sample with the only difference that we build our map in a fragment instead of an activity.

We have already tried to clean and rebuild the project and to add multiDexEnabled true in the default config but nothing seems to work

our gradle now looks like this:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.example.tesi.citytracker"
        minSdkVersion 21
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.google.android.gms:play-services:11.6.0'
    implementation 'com.android.support:support-v4:26.0.2'
    implementation 'com.android.support:mediarouter-v7:26.0.2'
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:26.0.2'
    compile 'com.android.support:design:26.0.2'
    compile 'com.squareup.retrofit2:retrofit:2.3.0'
    compile 'com.squareup.retrofit2:converter-gson:2.3.0'
}

Any suggestion is welcome, we are kinda desperate rn.

edit 1

as suggested Im adding the whole gradle console error

    Executing tasks: [:app:assembleDebug]

Configuration 'compile' in project ':app' is deprecated. Use 'implementation' instead.
Configuration 'testCompile' in project ':app' is deprecated. Use 'testImplementation' instead.
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:checkDebugManifest UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:prepareLintJar UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:createDebugCompatibleScreenManifests UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:splitsDiscoveryTaskDebug UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:javaPreCompileDebug UP-TO-DATE
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:compileDebugNdk NO-SOURCE
:app:compileDebugSources UP-TO-DATE
:app:mergeDebugShaders UP-TO-DATE
:app:compileDebugShaders UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:transformClassesWithDexBuilderForDebug UP-TO-DATE
:app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED

FAILURE: Build failed with an exception.

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

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 3s

19 actionable tasks: 1 executed, 18 up-to-date
  • Please take a look at my answer https://stackoverflow.com/questions/32798816/unexpected-top-level-exception-com-android-dex-dexexception-multiple-dex-files/33786747#33786747 This talks about why not to include all of google play services. You are also on an old version update to 11.6.2. You should also run ./gradlew app:dependencies to list dependencies to check for duplicate libraries and inconsistent version numbers – kandroidj Nov 30 '17 at 16:32
  • Beyond that, I suggest that you edit your question and post the entire output of your Gradle Console, not just the two lines that you have right now. The details of your problem usually lie elsewhere in the Gradle Console output. – CommonsWare Nov 30 '17 at 16:33
  • 1
    @inner_class7 thank you very much, we changed the gradle including only map, location and services and its actualy working. I cannot express how gratefull we are. You are a hero today – The Impredictable Soritustedim Nov 30 '17 at 17:09

0 Answers0