Gradle构建不起作用libGDX Javahome错误

时间:2017-03-20 21:13:14

标签: java android libgdx java-home

我一直试图让libGDX解决问题,但在gradle建设时我总是遇到错误。

这是错误

Gradle sync failed: 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 (x86)\JetBrains\IntelliJ IDEA 2016.3.2\jre,daemonRegistryDir=C:\Users\Shawn\.gradle\daemon,pid=396,idleTimeout=null,daemonOpts=-Xms128m,-Xmx1500m,-Dfile.encoding=windows-1252,-Duser.country=US,-Duser.language=en,-Duser.variant]
        Actual: DefaultDaemonContext[uid=be8febdd-0d00-4ec8-98ce-6076e4f5a2eb,javaHome=C:\Program Files\Java\jdk1.8.0_111,daemonRegistryDir=C:\Users\Shawn\.gradle\daemon,pid=9116,idleTimeout=60000,daemonOpts=-Xms128m,-Xmx1500m,-Dfile.encoding=windows-1252,-Duser.country=US,-Duser.language=en,-Duser.variant]
        Consult IDE log for more details (Help | Show Log)

我的项目结构 Structure

build.gradle文件

Java home isn't defined

解决:

我通过在gradle.properties文件中添加一行来修复它

org.gradle.java.home=C:/Program Files/Java/jdk1.8.0_111

1 个答案:

答案 0 :(得分:0)

更改您的构建工具

转到选项(ctrl + alt + s)并选择图片中的标签,然后将JRE更改为实际的jdk1.8.0_111(如果您选择的很少,请尝试选择它们并运行您的应用):< / p>

enter image description here

如果它不工作,我们会更进一步:D

Android Studio

  1. 关闭Android Studio
  2. 转到Android Studio目录并运行studio64.exe而不是studio.exe
  3. 检查错误是否仍然存在。
  4. Android Studio的默认目录:C:\Program Files\Android\Android Studio\bin

    enter image description here

    InteliJ IDEA

    相同的步骤,而不是idea64.exe

    运行idea.exe

    Android Studio的默认(我的)目录:

    C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 2016.3\bin

    enter image description here