スポンサーリンク

This version of the Android Support plugin for IntelliJ IDEA (or Android Studio) cannot open this project, please retry with version 2021.1.1 or newer.

スポンサーリンク

環境

自分でも調査した限り,IntellijでAndroidを動かそうとしている人がよくはまっているように見えました.私のIntellij環境は以下です.なお,Android Studio使っている方とIntellijの方両方に分かるように対策を記載します.

  • IntelliJ IDEA 2021.3.1 (Ultimate Edition)

これで2022/1/27コミットの以下をcloneしてビルドしようとした時にタイトル通りのエラーが発生します.(おそらくOwl Projectだけビルドが成功します.)

GitHub - android/compose-samples: Official Jetpack Compose samples.
Official Jetpack Compose samples. Contribute to android/compose-samples development by creating an account on GitHub.

please retry with version 2021.1.1 or newer

ちなみにこの2021.1.1はIntellijのversioningではなく,Android Studioのversioningを指しているので, Android Studio Bumblebee (2021.1.1) を使用しろという意味です.

対策

Intellij

Owl プロジェクトとその他のビルドスクリプトの差分を取った結果,AGP(Android Gradle Plugin)のバージョンが異なっており,以下のようにOwlプロジェクトに合わせる形で,AGPのバージョンを7.1.0から7.0.3に修正すると問題なくビルドできます.

dependencies {
    classpath 'com.android.tools.build:gradle:7.0.3'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}

一部のプロジェクトはbuildSrc内のDependencies.ktで管理しているので,その該当部分を書き換えてください

Android Studio

2つ対策があります.

  • Android Studio Bumblebee (2021.1.1) にアップデートする.
  • 上記の通り,AGPを7.0.xにダウングレードする

AGPとはなに?

公式ドキュメントは以下です.

Android Gradle プラグインのリリースノート  |  Android デベロッパー  |  Android Developers
Android Studio ビルドシステムは Gradle をベースにしており、Android Gradle プラグインは Android アプリのビルドに役立つ複数の機能を追加します。

Gradleを使用するAndroid Studio独自のビルドシステムです.そのため,AGPのバージョンとGradleのバージョンを正しく指定する必要があります.AGPごとにGradleの最低要件が上記サイトで定義されていますので,ご確認ください.

定義方法は以下です.

  • AGPのバージョン指定(build.gradle)
buildscript {
    dependencies {
        classpath 'com.android.tools.build:gradle:7.0.3'
    }
}
  • gradleのバージョン指定(gradle/wrapper/gradle-wrapper.properties)
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.2-bin.zip

今回の問題は?

Intellij 2021.3.1はRelease Noteにて,Android Studio Arctic Foxをサポートしている旨を宣言しています.

IntelliJ IDEA now supports Android Studio Arctic Fox, 2020.3.1

What's new in IntelliJ IDEA
Check out the new features and updates in the latest IntelliJ IDEA release.

したがって,Android Studio Arctic Fox 2020.3.1の機能は全て使用可能であるので,問題はAndroid Studio Arctic Fox自体にあります.

Android Studio Arctic Fox 2020.3.1はAGP 7.1.0をサポートしていない

AGP7.1.0をサポートしているのは,公式リリースにある通りAndroid Studio Bumblebee (2021.1.1)からになります.従って,Intellijベースで使用するためにはもう少し待たないといけません.EAPでも2022/1/31現在でも記載されていないので,当分はないかもしれませんね.

IntellijがAGPのどこまで対応しているか一覧表がほしいですね・・?

タイトルとURLをコピーしました