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

Flutter集成Firebase Auth时遭遇Kotlin版本不兼容编译错误

Firebase Auth集成Flutter时的Kotlin版本不兼容问题

我在学习将Firebase Auth集成到Flutter项目的初始设置过程中遇到错误,问题涉及项目级build.gradle文件,且我使用的是最新版本的Kotlin。

错误信息如下:

C:/Users/hp/.gradle/caches/transforms-3/648640f83817e7438e3934ba83addfe2/transformed/jetified-play-services-measurement-api-22.0.1-api.jar!/META-INF/java.com.google.android.gmscore.integ.client.measurement_api_measurement_api.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
   > Compilation error. See log for more details

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 3s

┌─ Flutter Fix ──────────────────────────────────────────────────────────────────────────────┐
│ [!] Your project requires a newer version of the Kotlin Gradle plugin.                     │
│ Find the latest version on https://kotlinlang.org/docs/releases.html#release-details, then │
│ update D:\phone_auth\android\build.gradle:                                                 │
│ ext.kotlin_version = '<latest-version>'                                                    │
└────────────────────────────────────────────────────────────────────────────────────────────┘
Error: Gradle task assembleDebug failed with exit code 1

解决方法

  • 打开项目根目录下的android/build.gradle文件
  • 找到代码行ext.kotlin_version = '<当前版本>'
  • 将版本号替换为1.9.0或更高的稳定版(错误提示依赖的元数据版本为1.9.0,需保证插件版本与之兼容)
  • 同步Gradle配置后重新运行项目

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.22 15:33:10