Gradle sync fails in new project
Hello,
I've just installed intelliJ IDEA Ultimate through the toolbox and downloaded the latest JDK and installed it without the public JRE.
However, when following the Getting Started guide for plugin development with Gradle I get an error right after IntelliJ is done downloading Gradle 4.4 saying sync failed: Could not determine Java version using executable C:\Program Files\Java\jdk-10.0.1\bin\java.exe.
When creating the Gradle project in the New Project Wizard I have two options for the Project SDK, 10 (java version 10.0.1) and IntelliJ IDEA IU-181 (java version 10.0.1) where the latter is the only option when choosing the IntelliJ Platform Plugin option in the wizard. I've tried both to no avail.
What am I doing wrong?
I've seen similar threads but the common solution is to update everything but I already am on the latest JDK (10.0.1) and intelliJ (2018.1.5) and as intelliJ is downloading Gradle itself I guess 4.4 is the right Gradle version :-)
Please sign in to leave a comment.
It might be the Gradle version after all. According to another thread only Gradle 4.7+ has JDK 10 support. So is there any way to specify what version of Gradle IntelliJ should download?
IntelliJ doesn't download Gradle, it's on you or on Gradle itself. See details here: https://gradle.org/install/
I wanted to avoid installing a local copy of Gradle except what gets downloaded to my HOME/.gradle folder
As you can see on the screenshots above the default wrapper option does download a gradle 4.4 binary. Just as stated on the official Jetbrains gradle docs the default wrapper is the recommended option; "We recommend that you use this option to eliminate any Gradle version problems in your project"
I can see that to update the wrapper version I can run
./gradlew wrapper --gradle-version x.y
but that would require to install Gradle as well. Isn't it possible to set the version without installing gradle myself?> As you can see on the screenshots above the default wrapper option does download a gradle 4.4 binary.
Yes, I know, that's what I'm talking about, it's not IntelliJ downloads Gradle, it's Gradle wrapper and you're controlling it via `build.script` and Gradle wrapper properties file.
> Isn't it possible to set the version without installing gradle myself?
There is no way to upgrade Gradle distribution which doesn't exist. But you already have Gradle 4.4 and its wrapper, so what's the problem with this?
I'm honestly not sure what I'm doing wrong :-(
> But you already have Gradle 4.4 and its wrapper,
It's a fresh installation of Windows 10. I don't know how I got Gradle 4.4 at all - I only installed JDK 10.0.1 and intelliJ and tried to create a new gradle project.
> so what's the problem with this?
The problem is that gradle wont sync so the tasks mentioned in the guide isn't there. I don't even get the option of Action in New -> Plugin DevKit
As I said earlier it seems to be the match between JDK 10+ and Gradle 4.4 that's resulting in errors as I've read that only gradle 4.7+ supports JDK 10+
I've only ever used gradle once before so I'm not sure what I'm doing at all. Sorry for any stupid questions. I don't even know if this is the right place to ask - I just assumed I could tell intelliJ to download 4.8 instead of 4.4 for the default gradle wrapper somewhere as I saw 4.4 got downloaded.
> The problem is that gradle wont sync
You don't need to sync project in order to run upgrade from a terminal.
> I've only ever used gradle once before so I'm not sure what I'm doing at all.
I think you have following options:
- try to run wrapper upgrading
- use Java that is compatible with Gradle 4.4 (do you really need Java 10?).
- manually install newer Gradle version as it's described https://gradle.org/install/
- ask for advice at https://gradle-community.slack.com or at https://discuss.gradle.org/
> use Java that is compatible with Gradle 4.4 (do you really need Java 10?)
That's what I ended up doing. I installed JDK 8 so intelliJ would set up the gradle project and download the wrapper. With that wrapper i could specify the version of gradle with the gradlew wrapper command and upgraded to 4.7. With 4.7 downloaded I could change the JDK to version 10 again. :-)
Thank you for your help. I still don't get why it's 4.4 that gets downloaded initially though or why it isn't possible to change the version at the Project Creation Wizard
You're right, currently it's not possibly to specify gradle version in the `New project` wizard dialog for wrapper files generation. The bundled gradle tooling api jars version used by default.
You can track the issue status at https://youtrack.jetbrains.com/issue/IDEA-177325
Hi, I have just had this problem, and I tackled this on the basis that the solution should not be to downgrade the Java version, if only because most new java versions introduce security fixes, so it's better not to go backwards. I had upgraded Gradle to 5.4.1, and found a note at https://docs.gradle.org/5.4.1/release-notes.html, that it was necessary to use
./gradlew wrapper --gradle-version=5.4.1
(in the terminal) after download to ensure 5.4.1 is used. I restarted IDEA, and while I was a bit disappointed to find that it wanted to download Gradle 5.4.1 again, after a few minutes the build completed.