IntelliJ构建错误上下文不匹配 [英] IntelliJ Build Error Context Mismatch

查看:488
本文介绍了IntelliJ构建错误上下文不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用IntelliJ IDEA 15而不是Android Studio,但我在构建时遇到问题。我收到以下错误:

I want to use IntelliJ IDEA 15 instead of Android Studio, but I have a problem with building. I get the following error:

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 15.0\jre,daemonRegistryDir=C:\Users\Tim\.gradle\daemon,pid=1224,idleTimeout=null,daemonOpts=-XX:MaxPermSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xmx1024m,-Dfile.encoding=windows-1252,-Duser.country=DE,-Duser.language=de,-Duser.variant]
Actual: DefaultDaemonContext[uid=6fd89265-5686-4337-a75f-538209464d3a,javaHome=C:\Program Files\Java\jdk1.8.0_74,daemonRegistryDir=C:\Users\Tim\.gradle\daemon,pid=14128,idleTimeout=10800000,daemonOpts=-XX:MaxPermSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xmx1024m,-Dfile.encoding=windows-1252,-Duser.country=DE,-Duser.language=de,-Duser.variant]

我的错误是什么?正如您在下面的图片中看到的,一切都配置正确。

What is my mistake? As you can see on the following pictures everything is configured correctly.

我已经配置了JDK和Android工具,如下所示:

I have configured a JDK and the Android Tools as follows:



推荐答案

我在调查类似的问题时发现了这个问题,我解决了我的问题,所以也许我的经验会有所帮助。

I found this question while investigating a similar problem, and I solved mine, so maybe my experience will help.

我的问题与你的问题类似, Wanted 上下文有 javaHome 作为嵌入在IDEA安装文件夹中的JRE的路径,而 Actual 上下文将其作为第一个版本在我的道路上的Java的sion。我在网上发现了几个类似的错误报告,但没有一个IDEA嵌入式JRE作为通缉版本。

My problem was similar to yours in that the Wanted context had the javaHome as the path to the JRE embedded in the IDEA install folder, and the Actual context had it as the first version of Java on my path. I found several similar error reports online but none had the IDEA embedded JRE as the Wanted version.

通缉 Java版本碰巧是JRE的系统范围安装,而不是我为项目配置的JDK,也没有为 JAVA_HOME <设置的值/ code>,这让我非常怀疑(和困惑)。重新排序我的路径导致它使用另一个不需要的Java版本,所以它显然使用路径来选择运行什么,但不清楚为什么。我无法让IntelliJ的嵌入式JRE成为我的首选,因为我出于各种原因需要它成为JDK,所以我需要另一种解决方案。

The Wanted Java version happened to be a system-wide install of the JRE, and not the JDK I had configured for the project, nor the value set for JAVA_HOME, which made me very suspicious (and confused). Re-ordering my path caused it to use yet another "unwanted" version of Java, so it was clearly using the path to choose what to run, but it wasn't clear why. I couldn't make IntelliJ's embedded JRE be first on my path, because I needed that to be the JDK for various reasons, so I needed another solution.

我也注意到了(使用Process Explorer,因为我在Windows上),在失败的情况下,IntelliJ启动了许多 java.exe Gradle守护程序进程,并且肯定没有在我尝试开始构建之前,守护进程正在运行。

I also noticed (using Process Explorer, since I'm on Windows) that, in the failing case, IntelliJ launched a number of java.exe Gradle daemon processes, and that there were definitely no daemon processes running before I tried to start my build.

原因结果是我已在运行/调试配置对话框中定义了一个新配置,并将完整路径放在 Gradle项目中的 build.gradle 文件中: / code>字段,如下所示。 (我通过单击字段右侧的省略号(...)按钮来完成此操作,但我也可以直接输入它。)

The cause turned out to be that I had defined a new configuration in the "Run/Debug Configurations" dialog and put the full path to the build.gradle file in the Gradle project: field, as follows. (I did this by clicking the ellipsis (...) button to the right of the field, but I could also have entered it directly.)

但是,我应该做的是遵循现有配置中的模式,其中 Gradle项目:被指定为已注册项目,方法是单击该字段右侧的文件夹图标,在下图中以绿色突出显示。在这种情况下,字段的内容只是项目名称,并以略微不同的背景/前景色显示。 (我意外地发现右键单击此名称会将其替换为包含 build.gradle 的文件夹的路径,但如果您取消并再次开始编辑配置,则仍将仅显示为项目名称。)

However, what I should have done was follow the pattern in existing configurations, where the Gradle project: was specified as a "registered project", by clicking the "folder" icon to the right of the field, highlighted in green in the following image. In this case, the content of the field is just the project name, and is shown with subtly different background/foreground colours. (I accidentally discovered that right-clicking on this name will replace it with the path to the folder containing build.gradle, but if you cancel and start editing the configuration again, it will still appear as just the project name.)

进行此更改后,按预期构建配置,我发现只启动了一个 java.exe ,使用的路径与我在UI中的Gradle面板中运行了任务。

After making this change, the configuration built as expected, and I observed that only one java.exe was launched, using the same JDK path as when I ran tasks from the "Gradle" panel in the UI.

这篇关于IntelliJ构建错误上下文不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆