2021年8月8日日曜日

AndroidStudioでビルドしようとするとエラーでできない

Android Studio Arctic Foxにアップデートして、
新しいプロジェクト立ち上げてビルドすると以下のエラーになった。

Build file 'E:\Document\MyApplication11\app\build.gradle' line: 2

An exception occurred applying plugin request [id: 'com.android.application']
> Failed to apply plugin 'com.android.internal.application'.
   > Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
     You can try some of the following options:
       - changing the IDE settings.
       - changing the JAVA_HOME environment variable.
       - changing `org.gradle.java.home` in `gradle.properties`.

* 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.


訳: 
Android Gradleプラグインを実行するには、Java11が必要です。
現在、Java1.8を使用しています。

つまり、
JDKのバージョンを11にすればよいということだ。


対応方法

File -> Settings...を押下
子画面が出てくるので、
Build, Execution, Deployment > BuildTools > Gradle
を開く

赤枠のGradle SDKがjavaのバージョンになる。確かに現在1.8になっている。。
プルダウンに11がいたので、コレを選択してビルドしなおすとコンパイルできた!

※11がいない場合は、Download JDK...から11を落としてくれば良い



0 件のコメント:

コメントを投稿