Android Studio Koala Canary5升级AGP后出现Google Services同步错误
解决AGP 8.5.0-alpha05与Google Services插件的兼容性错误
问题概述
升级到Android Studio Koala(2024.1.1 Canary 5)后,按提示将Android Gradle Plugin(AGP)更新至8.5.0-alpha05,出现以下错误:
Querying the mapped value of flatmap(provider(task 'processDebugGoogleServices', class com.google.gms.googleservices.GoogleServicesTask)) before task ':app:processDebugGoogleServices' has completed is not supported
已使用最新版本的Google Services插件(4.4.1),但在Canary 4版本中可正常运行。
当前依赖版本
[versions] agp = "8.5.0-alpha05" koinVersion = "3.5.3" kspKoinVersion = "1.3.1" kotlin = "1.9.23" coreKtx = "1.12.0" junit = "4.13.2" junitVersion = "1.1.5" espressoCore = "3.5.1" lifecycleRuntimeKtx = "2.7.0" activityCompose = "1.8.2" composeBom = "2024.04.00" conventionalCommitsVersion = "3.1.3" ktorVersion = "2.3.3" logbackClassicVersion = "1.2.3" appcompat = "1.6.1" material = "1.11.0" kotlinxSerializationJsonVersion = "1.6.0" materialIconsExtended = "1.6.5" serializationVersion = "1.9.0" jetbrainsKotlinJvm = "1.9.21" ktfmtVersion = "0.17.0" coroutinesTest = "1.8.0" securityCryptoVersion = "1.0.0" timberVersion = "5.0.1" lifecycleRuntimeComposeVersion = "2.7.0" googleServices = "4.4.1" firebaseAuth = "22.3.1" material3Android = "1.2.1" uiTooling = "1.6.4" voyager = "1.0.0" kspVersion = "1.9.23-1.0.20"
Google Services插件配置:
googleServices = { id = "com.google.gms.google-services", version.ref = "googleServices" }
可能的解决方法
- 调整插件应用顺序:确保Google Services插件在所有代码生成类插件(如KSP、Room等)之后应用,将
id("com.google.gms.google-services")移至模块build.gradle.kts的插件列表末尾。 - 延迟配置避免提前查询:如果有自定义任务依赖
processDebugGoogleServices的输出,改用Gradle的provider或延迟属性获取值,避免在任务执行前查询结果。示例:val googleServicesOutput = tasks.named("processDebugGoogleServices").map { it.outputs.files.singleFile } // 在依赖任务中通过googleServicesOutput.get()获取,确保任务依赖已正确声明 - 尝试预览版插件:检查是否有适配AGP 8.5的Google Services预览版本,替换版本号为对应预览版(如
4.4.2-alpha01)测试兼容性。 - 临时回退AS版本:若上述方法无效,暂时回到Android Studio Koala Canary 4,等待插件或AGP修复该兼容性问题。
内容的提问来源于stack exchange,提问作者ant2009
相关产品推荐
相关产品推荐

