N Kaushik

Android Gradle plugin requires Java 11 to run - You are currently using Java 1.8

August 17, 2021

[Solved] Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8

This error is thrown if a different java version is selected in Android Studio and you are trying to run a project. It says that Java 11 is required for Android Gradle plugin and you are currently using Java 1.8, 1.7 etc.

Even if Java is installed on your system, this issue might occure. On my system, Java or jdk 14 and 13 are installed. But, I got it after one Android Studio update.

Full error:

Below is the complete full error thrown in Android Studio console:

Build file '/Users/xxx/AndroidStudioProjects/RadioButtons/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.

It looks like as below:

Gradle plugin error

Solution:

It is pretty simple to solve and the issue is self-explanatory. Change the path for jdk and done. If you have JDK installed, it will not take more than a minute.

Go to Preferences -> Build, Execution, Deployment -> Build Tools -> Gradle.

Check what is selected in Gradle JDK. In my case, 1.8 is selected.

Android studio gradle build failed

Click on it and it will show you all available options including detected SDKs, i.e. SDKs installed in your system.

Click on a version that is greater than 11.

detected jdk

Download JDK:

If your system doesn’t have any JDK installed, you can click on the Download JDK option in the above window.

It will show you another window as like below:

download jdk

Select the version, vendor and location for the JDK and click on Download to download it. Once download is done, you can change the path and it should work.


Subscribe to my Newsletter