You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Android项目中添加com.google.gms:google-services:4.3.14插件?

Google Services插件添加位置说明

1. 根目录build.gradle(项目级)

你需要在根目录的build.gradle中新增buildscript块,并将指定的classpath依赖放入其中。修改后的完整代码如下:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    dependencies {
        classpath 'com.google.gms:google-services:4.3.14'
        // 其他classpath依赖可在此添加
    }
}

plugins {
    id 'com.android.application' version '7.3.1' apply false
    id 'com.android.library' version '7.3.1' apply false
}

2. app模块build.gradle(应用级)

将apply plugin: 'com.google.gms.google-services'添加到文件末尾即可,修改后的完整代码如下:

plugins {
    id 'com.android.application'
}

android {
    namespace 'app.dependencieswalker'
    compileSdk 32

    defaultConfig {
        applicationId "app.dependencieswalker"
        minSdk 21
        targetSdk 32
        versionCode 1
        versionName "1.0"
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
        implementation "com.alcinoe:alcinoe-firebase:1.0.0"
}

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

补充:如果使用Android Studio较新的插件DSL写法,也可以直接在app模块的plugins块中添加插件ID,效果与上述apply plugin语句一致,写法如下:

plugins {
    id 'com.android.application'
    id 'com.google.gms.google-services'
}

内容的提问来源于stack exchange,提问作者zeus

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.11 15:05:29