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

Android Studio配置Firebase时google-services插件ID报错求助

Firebase配置报错解决方案:插件ID格式错误

错误原因

报错信息明确指出插件ID包含无效字符:,Gradle插件ID仅允许ASCII字母数字、.、_和-,因此com.google.gms:google-services不符合规则,需将冒号替换为点。

修改步骤

1. 修正模块级build.gradle的插件ID

找到模块目录下的build.gradle文件,将plugins块中的错误插件ID替换为正确格式:

原代码:

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

修改后:

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

2. 优化根目录build.gradle(可选,推荐)

当前根目录的build.gradle使用旧版buildscript声明classpath,可迁移至更简洁的plugins块写法(不影响功能,但更符合现代Gradle规范):

原代码:

buildscript{
    dependencies{
        classpath 'com.google.gms:google-services:4.3.15'
    }
}

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

修改后:

plugins {
    id 'com.android.application' version '7.4.2' apply false
    id 'com.android.library' version '7.4.2' apply false
    id 'com.google.gms.google-services' version '4.3.15' apply false
}

如果保留原buildscript写法,无需修改,只要模块插件ID正确即可正常工作。

3. 同步项目

修改完成后,点击Android Studio顶部的Sync Project with Gradle Files按钮,等待同步完成即可解决该报错。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.28 03:57:16