Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to complete Gradle execution (new project) - java home different

I downloaded Android Studio version [build 135.1653844] and created a new project. I am getting an error:

Failed to complete Gradle execution.
Cause:
The newly created daemon process has a different context than expected.
It won't be possible to reconnect to this daemon. 
Context mismatch: Java home is different.
Wanted: DefaultDaemonContext[uid=null,javaHome=C:\Program Files\Java\jdk1.6.0_45,daemonRegistryDir=C:\Users\gargn\.gradle\daemon,pid=1000,idleTimeout=null,daemonOpts=-XX:MaxPermSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xmx1024m,-Dfile.encoding=windows-1252,-Duser.country=US,-Duser.language=en,-Duser.variant]
Actual: DefaultDaemonContext[uid=9a6c3945-1d55-46d7-897b-4ed84a5707bb,javaHome=C:\Program Files\Java\jdk1.6.0_45\jre,daemonRegistryDir=C:\Users\gargn\.gradle\daemon,pid=1664,idleTimeout=10800000,daemonOpts=-XX:MaxPermSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xmx1024m,-Dfile.encoding=windows-1252,-Duser.country=US,-Duser.language=en,-Duser.variant]

My Java home is set to C:\Program Files\Java\jdk1.6.0_45 and I could not find any setting where I am using the jre path. I searched in all text files and could not find jre path as shown in the error above.

like image 733
nandan Avatar asked Jan 30 '15 22:01

nandan


People also ask

Does gradle use Java_home?

Gradle uses whatever JDK it finds in your path. Alternatively, you can set the JAVA_HOME environment variable to point to the installation directory of the desired JDK.

How do I change my gradle from org to Java home?

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.

What is Gradle_user_home?

GRADLE_USER_HOME. Specifies the Gradle user home directory (which defaults to $USER_HOME/. gradle if not set). JAVA_HOME. Specifies the JDK installation directory to use for the client VM.

What went wrong the supplied Javahome seems to be invalid I Cannot find the Java executable?

Its a common mistake to have \bin , while \bin should be in the PATH the java home is only your jdk folder like C:\Program Files\Java\jdk-15 . Deleted the jdk-17 folder and then uninstalled 31 and 30 version of sdk build tools and this should fix the issue .


2 Answers

Though I did not find the root cause where the different javaHomes have been taken from, at least I found a workaround that worked for me:

Try setting the following in your gradle.properties (either in %USERPROFILE%\.gradle\ or in your project build dir):

org.gradle.java.home=C:\Program Files\Java\jdk1.6.0_45\jre
like image 108
Stefan Neuhaus Avatar answered Sep 28 '22 11:09

Stefan Neuhaus


I deleted the jre from the installation file of inttellij, but when I tried to run intellij, i said that I tried to run a 32bit version of intellij, but no jre for 32bit was found, then I when to the intellij installation directory and run a 64bit version, and the problem was solved.

like image 21
Sterling Diaz Avatar answered Sep 28 '22 10:09

Sterling Diaz