3

Full Error --

An exception occurred applying plugin request [id: 'com.android.application']

Failed to apply plugin 'com.android.internal.application'. Android Gradle plugin requires Java 17 to run. You are currently using Java 11. Your current JDK is located in C:\Program Files\Java\jdk-11.0.13 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.

Just Created the new project and getting this error

Noman Baig
  • 134
  • 1
  • 9
  • 1
    Does [this](https://stackoverflow.com/questions/66980512/android-studio-error-android-gradle-plugin-requires-java-11-to-run-you-are-cur) help you? – Mirco0 May 30 '23 at 08:13
  • Please provide enough code so others can better understand or reproduce the problem. – Community May 30 '23 at 14:49

2 Answers2

4

Step 1: Just Download the Java 17. LINK

Step 2: Set environment variable for Java 17.

Step 3: In Android Studio Go to File → settings → Build, Execution, Deployment → Build Tools → Gradle → Gradle JDK And Select Java 17.

Step 4: Delete the Gradle Cache directory if you still get the error, on Mac it's located at ~/.gradle/caches

BUILD SUCCESSFUL :)

faebster
  • 727
  • 7
  • 13
Noman Baig
  • 134
  • 1
  • 9
  • 4
    Note that there's no need to explicitly install a JDK when you can use the embedded JDK that ships with your Android Studio installation – Edric May 30 '23 at 08:56
  • There is no Gradle JDK option there. Android Studio 2021-2 – ouai Jun 17 '23 at 19:46
  • I did it with the Embedded JDK as mention in the first comment. Take a look at this answer: https://stackoverflow.com/a/69064786/2597775. Also check your Gradle and AGP version. Mines are 8.0 and 8.0.2 respectively – sebasira Aug 23 '23 at 00:36
1

In my case I downloaded gradle JDK version corretto-17 Amazon, and changed Gradle JDK version to corretto and it worked.

Not worked others(ex: jbr-17, embedded JDK Jetbrains 17 and etc.)

nasibeyyubov
  • 1,735
  • 3
  • 11
  • 28