【问题标题】:Execution failed for task ':app:processDebugGoogleServices' Firebase&Android Studio任务 ':app:processDebugGoogleServices' Firebase&Android Studio 执行失败
【发布时间】:2026-01-09 19:40:02
【问题描述】:

我想将 Firebase-database 添加到我的 Android 应用程序中,但出现错误。

FAILURE:构建失败并出现异常。

  • 出了什么问题: 任务 ':app:processDebugGoogleServices' 执行失败。

    请通过更新 google-services 插件的版本(有关最新版本的信息可在 https://bintray.com/android/android-tools/com.google.gms.google-services/ 获得)或将 com.google.android.gms 的版本更新到 11.8.0 来解决版本冲突。

  • 尝试: 使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。运行 --scan 以获得完整的见解。

build.gradle 应用程序

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.example.lukasz.ogloszenia"
        minSdkVersion 14
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        targetCompatibility 1.8
        sourceCompatibility 1.8
        }
    }
    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation 'com.android.support:appcompat-v7:27.1.1'
        implementation 'com.android.support.constraint:constraint-layout:1.1.0'
        implementation 'com.android.support:support-v4:27.1.1'
        implementation 'com.google.firebase:firebase-database:11.8.0'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'com.android.support.test:runner:1.0.2'
        androidTestImplementation 'com.android.support.test.espresso:espresso-                    core:3.0.2'

        implementation 'com.google.android.gms:play-services-maps:12.0.1'
        compile 'com.google.gms:google-services:4.0.1'

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

有人可以帮我吗?

【问题讨论】:

    标签: java android firebase firebase-realtime-database


    【解决方案1】:

    改变这个:

    implementation 'com.google.firebase:firebase-database:11.8.0'
    

    到这里:

    implementation 'com.google.firebase:firebase-database:12.0.1'
    

    所有 google play 服务和 firebase 依赖项都需要具有相同的版本号。

    这从版本号 15 开始更改:

    每个匹配 com.google.android.gms:play-services-* 和 com.google.firebase:firebase-* 的 Maven 依赖项不再需要具有相同的版本号才能在构建时和运行时间。

    https://android-developers.googleblog.com/2018/05/announcing-new-sdk-versioning.html

    【讨论】: