无法为Flutter项目集成Firebase,Gradle构建插件报错
解决Flutter集成Firebase时gradle插件找不到问题
报错信息
FAILURE: Build failed with an exception.
Where:
Settings file '/Users/daniilsereda/StudioProjects/translator/android/settings.gradle' line: 29
- What went wrong:
Plugin [id: 'com.google.gms.google-services', version: '4.4.1', apply: false] was not found in any of the following sources:
- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Included Builds (None of the included builds contain this plugin)
- Plugin Repositories (could not resolve plugin artifact 'com.google.gms.google-services:com.google.gms.google-services.gradle.plugin:4.4.1')
Searched in the following repositories:
MavenRepo
Gradle Central Plugin Repository
解决步骤
检查settings.gradle的pluginManagement仓库配置,确保
google()仓库已正确添加且优先级合理:pluginManagement { repositories { google() gradlePluginPortal() mavenCentral() } }替换google-services插件版本为稳定兼容版,4.4.1可能存在同步异常,建议改用4.3.15:
修改settings.gradle中对应行:id 'com.google.gms.google-services' version '4.3.15' apply false清理gradle缓存并强制刷新依赖:
在项目根目录执行终端命令:cd android ./gradlew clean build --refresh-dependencies验证pubspec.yaml中Firebase依赖版本兼容性,确保使用最新稳定版的核心依赖:
dependencies: firebase_core: ^2.24.2
内容的提问来源于stack exchange,提问作者white-mamba
相关产品推荐
相关产品推荐

