IntelliJ Build Error Context Mismatch

前端 未结 13 1786
梦谈多话
梦谈多话 2020-11-30 07:34

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 create         


        
相关标签:
13条回答
  • 2020-11-30 07:36

    Add below in your gradle.propetries

    org.gradle.java.home=${sdk_path}

    for example:

    org.gradle.java.home=C:\Program Files (x86)\Java\jdk1.8.0_121

    Otherwise if you have memory heap warning.

    Please also add gradle.properties with below: org.gradle.jvmargs=-Xmx512m

    0 讨论(0)
  • 2020-11-30 07:36

    What worked for me was:

    • uninstalling intelliJ
    • Re-install intelliJ, but during the installation make sure you DON'T check "Download and install 64-bit JRE by JetBrains (will be used with the 64-bit launcher)"

    This made my project work again, (in both he 32 and 64 bit version).

    0 讨论(0)
  • 2020-11-30 07:37

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

    Observations

    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.

    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.

    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.

    Solution

    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.)

    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.)

    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.

    0 讨论(0)
  • 2020-11-30 07:38

    I solved this problem by renaming jre and jre64 folders to prevent idea from using them and setting JAVA_HOME to my other JDK 1.8 installation in the idea.bat file.

    0 讨论(0)
  • 2020-11-30 07:39

    I solved it by using 11.0.8-amzn instead of 11.0.8-zulu.

    Cost me two hours of my life to get the builds working again in the IDE

    0 讨论(0)
  • 2020-11-30 07:41

    In my case I only went to settings, searched for JDK, clicked Java Compiler, then I noticed the project bytecode version was missing. So I only checked 1.8 which is my Java build version. And that was it for me.

    0 讨论(0)
提交回复
热议问题