【问题标题】:Adding Play Services dependency causes a conflict with Firebase添加 Play Services 依赖项会导致与 Firebase 发生冲突
【发布时间】:2016-04-11 01:53:13
【问题描述】:

我需要将 Firebase 和 Google Play 服务(用于地图)添加到我的应用程序中,但是将它们作为依赖项添加到 build.gradle 会在运行时出现此错误:

* 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

对 StackOverflow 的搜索表明这是由重复的库引起的,但我不确定如何找出正在复制的库。问题肯定出在 Firebase 和 Google Play 服务上,因为应用程序单独成功构建,但不包括两者。

这是我的 build.gradle 文件:

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'
}

非常感谢所有帮助!

【问题讨论】:

    标签: java android google-maps gradle firebase


    【解决方案1】:

    要调试重复的依赖关系,请查看依赖关系树:

    打开终端并输入

    gradlew dependencies <modulename>:dependencies
    

    (例如gradlew dependencies app:dependencies

    您还可以将输出范围缩小到一种配置:

    gradlew dependencies <modulename>:dependencies --configuration compile
    

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

    【讨论】:

    • 感谢您的回答!似乎没有任何重复的依赖项。您知道 dexDebug 错误的其他可能性吗?
    • 你可以尝试使用multiDex
    • MultiDex 如果您的库总和超过每个 dex 引用限制,则可以提供帮助。由于这些库非常大,这实际上可能是问题所在。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-27
    • 2019-04-17
    • 1970-01-01
    • 2015-09-12
    • 2023-03-14
    相关资源
    最近更新 更多