web-dev-qa-db-fra.com

Échec de la construction - "Impossible de fusionner Dex"

J'essaie de construire le projet et j'obtiens l'erreur suivante:

 enter image description here

Après avoir exécuté avec --stackrace c'est l'erreur que je reçois:

 enter image description here

et voici la log que je reçois:

FAILURE: Build failed with an exception.

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

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

    * Exception is:
    org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.Java:100)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.Java:70)
        at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.Java:63)
        at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.Java:54)
        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.Java:58)
        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.Java:88)
        at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.Java:52)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.Java:52)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.Java:54)
        at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.Java:43)
        at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.Java:34)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.Java:248)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.Java:336)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.Java:328)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.Java:197)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.Java:107)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.Java:241)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.Java:230)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.Java:124)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.Java:80)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.Java:105)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.Java:99)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.Java:625)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.Java:580)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.Java:99)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.Java:63)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.Java:46)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.Java:55)
    Caused by: Java.lang.RuntimeException: com.Android.builder.dexing.DexArchiveMergerException: Unable to merge dex
        at com.Android.builder.dexing.DxDexArchiveMerger.mergeMultidex(DxDexArchiveMerger.Java:266)
        at com.Android.builder.dexing.DxDexArchiveMerger.mergeDexArchives(DxDexArchiveMerger.Java:133)
        at com.Android.build.gradle.internal.transforms.DexMergerTransformCallable.call(DexMergerTransformCallable.Java:97)
        at com.Android.build.gradle.internal.transforms.ExternalLibsMergerTransform.transform(ExternalLibsMergerTransform.kt:121)
        at com.Android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.Java:222)
        at com.Android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.Java:218)
        at com.Android.builder.profile.ThreadRecorder.record(ThreadRecorder.Java:102)
        at com.Android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.Java:213)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.Java:73)
        at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.Java:173)
        at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.Java:134)
        at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.Java:121)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.Java:122)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.Java:336)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.Java:328)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.Java:197)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.Java:107)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.Java:111)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.Java:92)
        ... 27 more
    Caused by: com.Android.builder.dexing.DexArchiveMergerException: Unable to merge dex
        at com.Android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.Java:72)
        at com.Android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.Java:36)
        ... 46 more
    Caused by: com.Android.dex.DexException: Multiple dex files define Lcom/google/common/hash/AbstractNonStreamingHashFunction$ExposedByteArrayOutputStream;
        at com.Android.dx.merge.DexMerger.readSortableTypes(DexMerger.Java:661)
        at com.Android.dx.merge.DexMerger.getSortedTypes(DexMerger.Java:616)
        at com.Android.dx.merge.DexMerger.mergeClassDefs(DexMerger.Java:598)
        at com.Android.dx.merge.DexMerger.mergeDexes(DexMerger.Java:171)
        at com.Android.dx.merge.DexMerger.merge(DexMerger.Java:198)
        at com.Android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.Java:61)
        ... 47 more


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

    BUILD FAILED in 4s

Ceci est mon niveau d'application:

apply plugin: 'com.Android.application'

Android {
    compileSdkVersion 26
    buildToolsVersion '27.0.0'
    defaultConfig {
        applicationId "com.tal.wikirace"
        multiDexEnabled true
        minSdkVersion 23
        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'
        }
    }
    productFlavors {
    }
}

configurations {
    compile.exclude group: "org.Apache.httpcomponents", module: "httpclient"
}

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


    compile 'com.Android.support.constraint:constraint-layout:1.0.2'
    compile 'com.google.api-client:google-api-client:1.22.0'
    compile'com.google.api-client:google-api-client-Android:1.22.0'
    compile  'com.Android.support:appcompat-v7:26.1.0'
    compile 'com.Android.volley:volley:1.0.0'
    compile 'com.google.code.gson:gson:2.8.1'
    compile 'com.google.code.findbugs:jsr305:2.0.1'
    compile 'com.google.http-client:google-http-client:1.22.0'
    compile 'com.Android.support:design:26.1.0'

    compile 'com.google.Android.gms:play-services-auth:11.4.2'
    compile 'com.google.firebase:firebase-auth:11.4.2'
    compile 'com.google.firebase:firebase-messaging:11.4.2'
    compile 'com.google.firebase:firebase-firestore:11.4.2'
}
apply plugin: 'com.google.gms.google-services'

et voici mon projet:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()


        maven {
            url 'https://maven.google.com'
        }
    }
    dependencies {
        classpath 'com.Android.tools.build:gradle:3.0.0'
        classpath 'com.google.gms:google-services:3.1.1'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        maven {
            url 'https://maven.google.com'
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Ceci est ma version actuelle du SDK tools:

 enter image description here


Ce que j'ai essayé:

  • Supprimez les .gradle et que exécutez clean et rebuild.

  • En cours Invalidate Caches/Restart

5
Tal Barda

Supprimer les lignes suivantes de votre fichier .gradle

compile 'com.google.api-client:google-api-client:1.22.0'
compile 'com.google.api-client:google-api-client-Android:1.22.0'
1
mksengun

Dans\plates-formes\Android\project.properties, remplacez le numéro de base et le numéro d'annonce par «+» uniquement.

com.google.Android.gms:play-services-base:+
com.google.Android.gms:play-services-ads:+

Une autre façon: installer un plugin cordova pour créer la version automatiquement

cordova plugin add cordova-Android-play-services-gradle-release
1
Mr.Zon

Ceci est résolu en ajoutant:

cordova.system.library.7=com.Android.support:appcompat-v7:27.1.0

dans votre fichier project.properties, assurez-vous que Firebase et les services Google ont le même numéro de version. 

0
eatmeimadanish