ОШИБКА Несколько файлов dex определяют Lcom / google / android / gms / location / place / zza; - PullRequest
0 голосов
/ 23 июня 2018

Я сталкиваюсь с этой проблемой от 2 дней, до сих пор не найдено никакого решения. Я пытался изменить версии библиотек, очистить и собрать проект, сделать недействительным кеш и т. Д.

Ниже мой файл build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.root.ambulancetracking"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }

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


dependencies {
    //noinspection GradleCompatible
    implementation 'com.google.android.gms:play-services-maps:15.0.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:27.1.1'
    compile 'com.mcxiaoke.volley:library-aar:1.0.0'
    compile 'com.android.support:support-v4:27.1.1'
    compile 'com.android.support:design:27.1.1'
    compile 'com.android.support:recyclerview-v7:27.1.1'
    compile 'com.android.support:cardview-v7:27.1.1'
    compile 'com.google.firebase:firebase-messaging:17.0.0'
    compile 'com.google.firebase:firebase-core:16.0.0'
    compile 'com.google.android.gms:play-services-location:15.0.1'
    compile 'com.google.code.gson:gson:2.8.0'
    compile 'com.github.ar-android:DrawRouteMaps:1.0.0'
}
apply plugin: 'com.google.gms.google-services'
configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '25.3.1'
            }
        }
    }
}

И ниже build.gradle (проект):

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

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath 'com.google.gms:google-services:3.2.0'

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

allprojects {
    repositories {
        maven { url "https://jitpack.io" }
        google()
        jcenter()
    }
}

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

Вот что я получаю в окне сообщения.

Information:Gradle tasks [:app:assembleDebug]
Error:java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
Error:java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
Error:com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
Error:com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/location/places/zza;
Information:BUILD FAILED in 1m 22s
Information:4 errors
Information:0 warnings
Information:See complete output in console

Я старался изо всех сил

Пожалуйста, любая помощь будет оценена.
Большое спасибо за ваше время и помощь в этом вопросе.

Ответы [ 3 ]

0 голосов
/ 23 июня 2018

ваша версия конфликтует

compile 'com.google.firebase:firebase-messaging:17.0.0'
compile 'com.google.firebase:firebase-core:16.0.0'
compile 'com.google.android.gms:play-services-location:15.0.1'

скрытно для следующих строк:

compile 'com.google.firebase:firebase-messaging:17.0.0'
compile 'com.google.firebase:firebase-core:17.0.0'
compile 'com.google.android.gms:play-services-location:17.0.0'
0 голосов
/ 23 июня 2018

Вам необходимо использовать одну и ту же версию Firebase и Google Play Service, если вы используете плагин сервиса Google Play ниже 3.3.0.

Если вы хотите использовать несколько версий Firebase и Google Play Service (начиная с версии 15) вам необходимо использовать плагин сервиса Google Play 3.3.0 .Итак, измените ваш проект build.gradle на:

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

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath 'com.google.gms:google-services:3.3.0'

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

...

Наконец, не забывайте всегда добавлять следующую строку:

apply plugin: 'com.google.gms.google-services'

в bottom вашего приложения build.gradle.

0 голосов
/ 23 июня 2018

пожалуйста, добавьте эту библиотеку, чтобы решить эту проблему

implementation 'com.android.support:multidex:1.0.3'

также включите мультидекс в классе вашего приложения

    @Override
    public void onCreate() {
        super.onCreate();
        MultiDex.install(this);
  }
...