如何解决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
相关产品推荐
相关产品推荐

