141
37

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Android Gradle plugin requires Java 11と言われてSyncできないときの対処法

Last updated at Posted at 2021-04-15

AGP 7.0.0-alpha02からJava 11が必須になったようです。
https://developers-jp.googleblog.com/2020/12/announcing-android-gradle-plugin.html
あの設定どこだっけってときどきなって、かなり高確率で最初に当たるので、メモしておきます。

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

最近は以下のようなエラーメッセージでも同様のことが起こるようなので、対処方法を試してみてください。

  • Java 11にしかないパラメーターを使っているパターン

Unrecognized VM option 'MaxPermSize=2048m'

  • Toolchainで11を使っているパターン

A problem occurred configuring project ':app'.
Could not determine the dependencies of task ':build-logic:compileKotlin'.
No matching toolchains found for requested specification: {languageVersion=11, vendor=any, implementation=vendor-specific}.
> No locally installed toolchains match (see https://docs.gradle.org/8.1.1/userguide/toolchains.html#sec:auto_detection) and toolchain download repositories have not been configured (see https://docs.gradle.org/8.1.1/userguide/toolchains.html#sub:download_repositories).

対処法

Gradleの設定を開いて、

image.png
image.png

Android Studioに入っているJDKを選ぶだけです。

image.png

141
37
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
141
37

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?