0

Every time I create a new project in Android Studio I'm met with the following build error:

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

I already know how to change the project settings to use JDK 11, but I'd like to fix this problem permanently for all new projects.

How can I get Android Studio / Gradle to use JDK 11 instead of 1.8 for all new projects?

donturner
  • 14,429
  • 8
  • 52
  • 76
  • I was able to workaround this by removing JDK 1.8 (`mv /Library/Java/JavaVirtualMachines/jdk1.8.0_221.jdk /tmp/`), then doing `Android Studio-> Invalidate Caches and Restart`, however, I'd be interested to know if there's a solution which doesn't involve such a drastic step. – donturner Jan 23 '22 at 18:18
  • did you set the JAVA_HOME environment variable to your system variables – Vishal Beep Jan 24 '22 at 06:06
  • Yes, `JAVA_HOME` is set to the Java 11 SDK installation path. – donturner Jan 24 '22 at 17:48

1 Answers1

0

First Click on File > Project Structure or you can press Ctrl + Alt + Shift + S

then follow these images

Go to SDK location:

and there you can see JDK location was moved to Gradle settings and you can click there then you will see a new window like shown in next image.

enter image description here

Now you can the JDK location

enter image description here

Vishal Beep
  • 1,258
  • 7
  • 22
  • 1
    That will change the gradle JDK for the _current_ project. My question was how to change it for _every new_ project (so I don't to go through that rigmarole every time I create a new project). – donturner Jan 24 '22 at 17:46