I have two JDKs installed on my Windows 10 computer:
- OpenJDK version 8
- JDK 11 which comes built-in with Android Studio (under
C:\Program Files\Android\Android Studio\jre
). (Minor unrelated question: Why is the JDK under a folder namedjre
? Doesn't make any sense...)
Every time I create a new empty project from scratch and try to run it, Android Studio complains:
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`.
I think this happens because my PATH
environment variable points to OpenJDK 8. Ideally I shouldn't touch this (because I use it for other projects).
I normally solve this problem by going to File -> Settings -> Build, Execution, Deployment -> Build tools -> Gradle
and set the JDK to Android's Built-in JDK.
But this is too tiresome: I need to do this for EVERY project I create. I haven't found a way to tell Android Studio: "Hey, use your own JDK by default for every new project, and stop complaining."
I want to know if such way exists.