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

如何解决Flutter项目中‘需更新Kotlin Gradle插件’报错?

Flutter构建Release APK失败:compileReleaseKotlin任务报错

错误日志

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileReleaseKotlin'.
> 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 2m 56s
Running Gradle task 'assembleRelease'... 177.3s

问题核心

任务:app:compileReleaseKotlin执行失败,根源是项目使用的Kotlin Gradle插件版本过低,与当前项目依赖环境不兼容。

解决方案

  • 若项目基于Flutter 3.19及以上版本创建:
    打开项目路径下的android/settings.gradle文件,找到plugins块内的org.jetbrains.kotlin.android插件,将其版本号更新为Kotlin最新稳定版。
  • 若项目是Flutter 3.19之前创建的:
    打开项目路径下的android/build.gradle文件,更新ext.kotlin_version = ''中的版本号为Kotlin最新稳定版。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.14 05:52:32