# Required Kotlin version

> Flutter apps built for the Android platform now require Kotlin 1.5.31 or greater.




:::important
These breaking change docs are accurate, as of the release
under which they are published. Over time, the
workarounds described here might become inaccurate.
We don't, in general, keep these breaking change docs up
to date as of each release.

这些破坏性改动文档的准确性仅限于其发布时对应的版本。
随着时间的推移，文档中描述的方案可能会逐渐失效。
通常情况下，我们不会在每次发布新版本时都对这些文档进行同步更新。

The [breaking change index file](/release/breaking-changes)
lists the docs created for each release.

[破坏性改动列表](/release/breaking-changes) 
列出了每个版本的文档。

:::


:::important
As of Flutter 3.16, the default Gradle build scripts differ across
Flutter versions. For example, the Kotlin version is now
configured in the `android/settings.gradle` file.
If you have generated your project with
an older version of Flutter, it's advisable to upgrade
your build scripts to the newest form. For more information,
see [Issue 10380][] and [Issue 135392].
:::

[Issue 10380]:  https://github.com/cfug/flutter.cn/issues/10380
[Issue 135392]: https://github.com/flutter/flutter/issues/135392

## Summary

To build a Flutter app for Android, Kotlin 1.5.31 or greater is required.

If your app uses a lower version,
you will receive the following error message:

```plaintext noHighlight
┌─ 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>'                                  │
│                                                                          │
└──────────────────────────────────────────────────────────────────────────┘
```

## Context

Flutter added support for [foldable devices][1] on Android.
This required adding an AndroidX dependency to the Flutter embedding that
requires apps to use Kotlin 1.5.31 or greater.

## Description of change

A Flutter app compiled for Android now includes the Gradle dependency
`androidx.window:window-java`.

## Migration guide

Open `<app-src>/android/build.gradle`, and change `ext.kotlin_version`:

```groovy diff
  buildscript {
-     ext.kotlin_version = '1.3.50'
+     ext.kotlin_version = '1.5.31'
```

## Timeline

Landed in version: v2.9.0 beta<br>
In stable release: 2.10

## References

Relevant PR:

* [PR 29585: Display Features support][]


[PR 29585: Display Features support]: https://github.com/flutter/engine/pull/29585

[1]: https://developer.android.google.cn/guide/topics/large-screens/learn-about-foldables

