LoginSignup
0
0

FlutterでAndroidビルド時に「your project requires a newer version of the kotlin gradle plugin.」というエラーになる

Last updated at Posted at 2024-06-25

自分の環境

  • macOS Sonoma 14.4
  • Flutter 3.22

経緯

AndroidのエミュレータでFlutterアプリのデバッグのためビルドしたところ、「your project requires a newer version of the kotlin gradle plugin.」というエラーが出てしまった。
調べても対応方法で一致するものを見つけられなかったので、備忘録として残します。

原因

要求するKotlinおよびGradleのバージョンが不一致であること。
私の場合はGradleは問題なく、Kotlinが原因だったのでKotlinのバージョンアップで対応しました。

よく見かける対処法

/android/build.gradle のbuildscriptを編集するというもの。
しかし3.16以降だとこの記載が消えたらしい。(なぜ)
そのためこの方法を諦めました。

スクリーンショット 2024-06-26 5.39.37.png

実際にやったこと

/android/setting.gradle を変更しました。
以下のようにpluginsの一番最後にkotlinのバージョンを指定しました。(もともと2行だったので追加してます)

スクリーンショット 2024-06-26 5.41.22.png

ペースト用:

id "org.jetbrains.kotlin.android" version "1.9.10" apply false

Kotlinのバージョンは以下から確認できます。
https://kotlinlang.org/docs/releases.html#release-details

これでビルドが通るようになりました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0