问题描述
我下载了 Android Studio 版本 [build 135.1653844] 并创建了一个新项目.我收到一个错误:
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]
我的 Java 主页设置为 C:\Program Files\Java\jdk1.6.0_45
并且我在使用 jre
路径的地方找不到任何设置.我搜索了所有文本文件,但找不到 jre
路径,如上面的错误所示.
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.
推荐答案
虽然我没有找到不同 javaHomes 的根本原因,但至少我找到了一个对我有用的解决方法:
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:
尝试在您的 gradle.properties
(在 %USERPROFILE%\.gradle\
或您的项目构建目录中)中设置以下内容:
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
这篇关于无法完成 Gradle 执行(新项目) - java home 不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!