Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle is not setting the javahome in mention in gradle.bat

When running my Project, I get this error:

Error:Invalid Gradle JDK configuration found. <a href='#open_external_system_settings'>Open Gradle Settings</a> 
Platform SDK does not point to valid JDK (C:/Program Files/Java/jdk1.7.0_71)

To fix this I tried setting my javahome in gradle.build as

:findJavaFromJavaHome set JAVA_HOME=C:\Data\jdk1.7.0_55  set JAVA_EXE=%JAVA_HOME%/bin/java.exe

Still I get the same error. Can someone help pls.

like image 781
Prabhuraj Avatar asked Mar 31 '15 09:03

Prabhuraj


People also ask

Which Gradle version is compatible with java 11?

The minimum version of Gradle that supports Java 11 is 5.0 . You would need to upgrade to version 7.0 or above for Android.

Does Gradle use Java_home?

By default, Gradle uses the java version from the JAVA_HOME environment variable path configured in the machine, and JAVA_HOME points to JDK installed on the machine.

How do I run a Gradle with a specific version of java?

Right click on the deploy or any other task and select "Open Gradle Run Configuration..." Then navigate to "Java Home" and paste your desired java path.


1 Answers

I had this same problem recently.

First make sure your Android Studio is updated.

Then, in the error center, it directs you to a pop-up window which you have to choose between "Local Gradle" and "Recommended Gradle wrapper" (Sorry if names doesn't exactly match since it was while ago)

For me it was set on Local Gradle and I changed it to the "recommended" one and waited so it rebuild the project. After it was done, the errors went away for second and I saw the same error and when I opened that window again, I saw it is set on "Local Gradle" again, although I chose the recommended one.

So I did chose recommended again and this time it was fixed and stayed fixed and I had no problem anymore!

Hope it works for you

UPDATE If the above way doesn't work, it should be because u have recently updated your Java. so see this question and change the path of your Java SDK

like image 123
Sam Ramezanli Avatar answered Oct 05 '22 07:10

Sam Ramezanli