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.
- changingorg.gradle.java.home
ingradle.properties
.
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.
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 :)