所需的 Kotlin 版本
概述
#要为 Android 构建 Flutter 应用,需要 Kotlin 1.5.31 或更高版本。
如果您的应用使用了较低版本,您将收到以下错误消息:
┌─ Flutter Fix ────────────────────────────────────────────────────────────┐
│ │
│ [!] Your project requires a newer version of the Kotlin Gradle plugin. │
│ Find the latest version on │
│ https://kotlinlang.org/docs/gradle.html#plugin-and-versions, then update │
│ <path-to-app>/android/build.gradle: │
│ ext.kotlin_version = '<latest-version>' │
│ │
└──────────────────────────────────────────────────────────────────────────┘
背景
#Flutter 在 Android 上添加了对 折叠屏设备 的支持。这需要向 Flutter 嵌入器添加 AndroidX 依赖项,该依赖项要求应用使用 Kotlin 1.5.31 或更高版本。
变更说明
#现已为 Android 编译的 Flutter 应用包含 Gradle 依赖项 androidx.window:window-java
。
迁移指南
#打开 <app-src>/android/build.gradle
,并修改 ext.kotlin_version
。
groovy
buildscript {
ext.kotlin_version = '1.3.50'
ext.kotlin_version = '1.5.31'
时间线
#已在版本中落地:v2.9.0 beta
稳定版本: 2.10
参考资料
#相关 PR