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

找不到ID为'com.google.gms.google-services'的Gradle插件求助

解决“找不到ID为'com.google.gms.google-services'的插件”问题

以下是针对性的修复步骤:

  • 确认根build.gradle的依赖配置位置
    确保com.google.gms:google-services的classpath声明在buildscript块的dependencies中,而非项目根级别的dependencies。正确的根配置结构示例:

    buildscript {
        ext.kotlin_version = "1.6.10" // 确保已定义kotlin_version变量
        repositories {
            google()
            mavenCentral()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:7.1.2'
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
            classpath 'com.google.gms:google-services:4.3.3'
        }
    }
    
    allprojects {
        repositories {
            google()
            mavenCentral()
        }
    }
    
  • 在App模块中正确应用插件
    打开app/build.gradle,在文件中添加插件声明:

    • 若使用旧版语法,在文件末尾添加:
      apply plugin: 'com.google.gms.google-services'
      
    • 若使用新版插件语法,在plugins块内添加:
      plugins {
          id 'com.android.application'
          id 'kotlin-android'
          id 'com.google.gms.google-services' // 新增此行
      }
      
  • 升级插件版本以兼容Gradle
    Gradle 7.1.2与google-services:4.3.3存在兼容性偏差,建议升级到适配版本,例如:

    classpath 'com.google.gms:google-services:4.4.0'
    
  • 清理并重新构建项目
    执行以下操作:

    1. 点击Android Studio工具栏的「Sync Project with Gradle Files」
    2. 依次执行「Build > Clean Project」和「Build > Rebuild Project」

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.23 05:10:00