简体   繁体   中英

Adding Play Services dependency causes a conflict with Firebase

I need to add both Firebase and Google Play Services (for Maps) into my app, but adding them as dependencies in build.gradle gives this error upon run:

* What went wrong:
Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: 
Process 'command 'C:\Program Files\Java\jdk1.8.0_45\bin\java.exe'' 
finished with non-zero exit value 2

A search of StackOverflow suggests that this is caused by duplicated libraries, but I am unsure how to find out which library is being duplicated. The problem definitely lies with Firebase and Google Play Services, as the app build successfully with each one on it's own, but not with both included.

Here is my build.gradle file:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "com.example.shounakk.myfirebasetest"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE-FIREBASE.txt'
        exclude 'META-INF/NOTICE'
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.2.1'
    compile 'com.android.support:design:23.2.1'
    compile 'com.google.android.gms:play-services:8.4.0'
    compile 'com.firebase:firebase-client-android:2.3.1'
}

All help is much appreciated!

To debug duplicated dependencies, have a look at the dependency tree:

Open the terminal and type

gradlew dependencies <modulename>:dependencies

(eg gradlew dependencies app:dependencies )

You can also narrow the output to one configuration:

gradlew dependencies <modulename>:dependencies --configuration compile

See https://docs.gradle.org/current/userguide/userguide_single.html#tutorial_gradle_command_line

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM