Gradle sync failed: The supplied javaHome seems to be invalid. I cannot find the java executable

Viewed 1771

The gradle build is trying to find the java jdk 8 at this location: C:\Program Files\Java\jdk1.8.0_101\bin\java.exe.

This fails because I uninstalled java 8 and want to use java 11 instead.

I have no idea where it is getting this value from.

I set a system environment variable for JAVA_HOME to C:\Program Files\Java\jdk-11.0.12\bin.

I also have specified the gradle JDK in the settings > Build, Execution Deployment > Build Tools > Gradle configurations to 11 (C:\Program Files\Java\jdk-11.0.12).

Also in the gradle.properties file (C:\Users\user name\StudioProjects\gradle.properties) I set org.gradle.java.home=C\:\\Program Files\\Java\\jdk-11.0.12.

Even after restarting (for the environment variable) gradle is still trying to use the java 8 JDK.

How can I get gradle to use the correct JDK?

1 Answers

Solved by invalidating the caches and restarting (apparently this setting was cached): File > Invalidate Caches / Restart

Related