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.
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.
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.
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.
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 .
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With