Android Gradle plugin requires Java 11 to run – troubleshooting

Last update April 18, 2023 at 07:08 AM

Android Gradle plugin requires Java 11 to run - this is the error shown in the most recent version of android studio. In this post, we show you how we solved it.

This month I set myself a personal challenge which is to read all the android documentation from google to update my programming knowledge.

One of the first things I had to do was install the newest version of android studio (which is Dolphin as I write) and apply everything I learned about Jetpack Compose.

The installation and project creation went well. Everything seemed to be fine until I compiled the project. The error I read in the terminal is:

Android Gradle plugin requires Java 11 to run

turning on Ubuntu 20.04 lts, ​​I show you in this post, the method I used to solve the problem.

World's Greatest Computer Scientists

Android Gradle plugin requires Java 11 to run – Solutions

If you read the rest of the error message, the IDE already offers you 3 solutions to make your project work.

You can try some of the following options: - changing the IDE settings. - changing the JAVA_HOME environment variable. - changing `` in ``.

Change the IDE configuration

The very first solution is to indicate in the android studio configuration that our project will use java 11 instead of the default jdk.

To do this, you must:

  • Go in Settings
  • Scroll section Build, Execution, Deployment
  • In BuildTools , click gradle
  • In the form on the right click on the drop-down field Gradle JDK and select JDK version higher than java 11.

The image below gives you an idea of ​​the general course.

Android Gradle plugin requires Java 11 to run

Change the JAVA_HOME environment variable

This solution didn't work for me but maybe it will be different for you.

To change the JAVA_HOME environment variable, follow the instructions in the article Configure JAVA_HOME via command in linux.

The problem I'm having with this solution is weird.

For example, the project can start working if I change the JAVA_HOME in the terminal of android studio. But you have to redo the exercise each time I launch the development environment.

If I apply the change from my linux terminal outside the IDE, the project won't work.

Again, this may vary from system to system, but for me it didn't work.

Modify the file

To apply this solution you must go to the file then add the line:

jdk_path is the path to your jdk.

To be sure to succeed, you have to read among the comments of the file. You may find the same script in the comments.

In my case, when I tried it, it didn't work. I don't know why but I must admit that I haven't done my research on this side too much.

If I got it right the first time, this was going to be by far my favorite solution. But hey, maybe by finding the solution, it will become yours.

Last update April 18, 2023 at 07:08 AM


I talked about the background which lead me to the android project compilation problem.

The snippet of the error message in question was Android Gradle plugin requires Java 11 to run.

In the rest of the message, there are already 3 proposed solutions to solve the version problem of your java. The proposition that worked for me is the very first one.

In this post I have detailed the steps to solve the error with the first method, offered by gradle.

I discussed the other two proposed solutions mentioning the pros and cons I encountered. Although attractive, it should not be hoped that these solutions work the first time.

Android Gradle plugin requires Java 11 to run