Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set GRADLE_LOCAL_JAVA_HOME?

Whenever I open an existing Android project in Android Studio for the first time, Android Studio sets the Gradle JDK to GRADLE_LOCAL_JAVA_HOME which points to the Android Studio's built-in JDK. I would like GRADLE_LOCAL_JAVA_HOME to point to a different JDK location (the same that I use in my JAVA_HOME and the one I have in PATH) but I can't figure out how to do it.

It's annoying that whenever I open a project I get a wrong JDK by default and I must open the settings and choose the one under JAVA_HOME manually. I would like Android Studio to pick up my custom default automatically instead.

Android Studio Gradle JDK dropdown Android Studio GRADLE_LOCAL_JAVA_HOME dropdown

This documentation says that:

GRADLE_LOCAL_JAVA_HOME: uses the java.home property in the .gradle/config.properties file which defaults to the JetBrains Runtime.

I hoped that I could change it globally somewhere and tried creating $HOME/.gradle/config.properties and putting java.home there but it doesn't work. Does it mean Android Studio respects only the config.properties file in the project's .gradle directory?

like image 301
Andrzej Zabost Avatar asked Jan 19 '26 07:01

Andrzej Zabost


1 Answers

you can override your Default JDK from File > New Project Setup > Setting for new project > Build, Execution, Deployment > Build Tools > Gradle and chagne the Default Gradle JDK.

FYI: https://issuetracker.google.com/issues/214428183#comment10

like image 89
Xuân Tùng Avatar answered Jan 20 '26 22:01

Xuân Tùng