Eclipse Gradle Plugin 'could not fetch model of type'
Asked Answered
S

19

27

I am running Eclipse Luna on OS X with Gradle IDE 3.6.1 and anytime I try to select a project from the gradle tasks panel I get the following error:

org.eclipse.osgi.internal.framework.EquinoxConfiguration$1
Could not fetch model of type 'EclipseProject' using Gradle distribution 
'https://services.gradle.org/distributions/gradle-2.0-bin.zip'.

Has anyone else run into this error? I can get to the URL specified to download the file myself. So, network connectivity shouldn't be the problem.

Smuts answered 9/10, 2014 at 14:48 Comment(0)
U
-2

Eclipse 4.4.1 broke Gradle Eclipse support with non-string values in system properties.This is fixed in the latest Gradle for the 3.6.2 release. Update your Gradle form this update-site: http://dist.springsource.com/snapshot/TOOLS/gradle/nightly

Unbutton answered 10/10, 2014 at 13:51 Comment(3)
Both the Gradle version number and the link you reference don't exist.Bombacaceous
I guess you mean not version 3.6.2 of Gradle (the newest is currently 2.13), but 3.6.2 (or newer) of the Gradle IDE? Unfortunately this also happends with Gradle IDE 3.7.3, on Eclipse 4.5.2.Demagogic
Gradle 4.4.1 from Dec 2017 has the same problem still.Impignorate
B
33

The problem is for the java version configured by default on the IDE (Eclipse or Spring Tool Suite). The error is the following:

enter image description here

To fix it, you can set the Java version supported by the Gradle version in Configure Workspace Setting option.

enter image description here

enter image description here

Finally, you can refresh your project o continue with your creation. Later all will be perfect.

enter image description here

Bolter answered 17/8, 2021 at 11:50 Comment(1)
Don't know why it's work and what will be the side-effects. But Thank youHendecagon
B
8

I had the same error in Eclipse Neon (version numbers were different, but otherwise same error). It looks like several different things can cause this error, but for me it was an incorrect property in [MyProject]/.settings/org.eclipse.buildship.core.prefs.

I had

connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)

but it needed to be

connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(2.13))

2.13 should be replaced with whatever version number output you get from gradle -version.

Coming back to add this: It turns out, the actual root problem was an incompatibility between Gradle versions. My build.gradle file worked fine with an old version of Gradle, but uses things that were deprecated and removed in later versions.

Solution is to click Finish immediately in the wizard instead of Next, and then fix the issues in the build.gradle.

Backfield answered 4/10, 2016 at 17:57 Comment(6)
That line is set by Windows/Preferences/Gradle. And it is NOT about THIS error 'could not fetch model of type'.Impignorate
Well, that's the error I was seeing, and changing that line fixed it for me.Backfield
Simply there are ANOTHER problem that is accidentally covered by some Gradle versions.Impignorate
Yeah, I don't doubt that at all, but I have no idea what that problem was. Maybe my fix didn't actually solve whatever the underlying problem was, but it made it so it was no longer an issue for me and allowed me to get back to work.Backfield
Of course. Nothing against it. And very often that temporary solution is enough. And it is a good and acceptable solution for you. But the authors of Eclipse plugins should still look for the bug. And as for me... It seems, I have to use Maven instead of Gradle because of the bug.Impignorate
@Gangnus, it turns out, the actual root problem was an incompatibility between Gradle versions. My build.gradle file worked fine with an old version of Gradle, but uses things that were deprecated and removed in later versions. Solution is to click Finish immediately in the wizard instead of Next, and then fix the issues in the build.gradle.Backfield
T
6

Bad reference in config.

Overwrite configuration:
Project -> Properties -> Gradle -> Override workspace settings ->
Specific Gradle version -> 4.x

Tooth answered 6/11, 2017 at 10:40 Comment(1)
I downloaded gradle 6.9 with Brew and specifying local installation caused me this error. This solution (setting specific version) worked like a charm for me.Anaesthesiology
K
3

You need to update Gradle Goto: Select 'Help > About Eclipse' (on Macs this is 'Eclipse > About Eclipse').

Click the 'Installation Details' button to display the installation details dialog. Look in the 'Installed Software' tab to see all the installed plugins.

Search for Gradle(Eclipse Plug-ins for Gradle) and Update.

It might take some time for first time after that.

Kraus answered 14/6, 2019 at 5:47 Comment(0)
J
1

Reason why it happens, cause new version of gradle is available to download. Once you download new version of gradle, your error will go away.

http://gradle.org/downloads

Jamesjamesian answered 6/2, 2015 at 2:41 Comment(2)
Sorry, I have Gradle 4.4.1, from the DEC 2017, and having the same error. Obviously, it is NOT the solution. Simply there are ANOTHER problem that is accidently covered by some Gradle versions. But we should solve the REAL problem, not check different versions for the case that some will work.Impignorate
I am using 4.6 and still facing same issue. It seems using maven is easier and simpler than GradleOffspring
T
1

I had the same error message using Eclipse 4.5 In my case the build file was having a error and I had to modify this line

eclipse.classpath  {
    plusConfigurations += configurations.providedCompile
}

into this

eclipse.classpath  {
    plusConfigurations += [configurations.providedCompile]
}

After that everything worked again.

Trodden answered 19/10, 2015 at 9:21 Comment(0)
G
1

I met the same problem, somebody suggested that the gradle project may be build by a old version. I solve the problem by the following step:

  1. modify the configuration in Eclipse, perfrence ->gradle ->gradle distribution . point it to an older version.
  2. delete the file in ./gradle/wrapper
  3. reload the program
Gaudy answered 23/2, 2016 at 4:59 Comment(0)
R
1

In my case, I forgot to put ending apostrophe ' for a value

Reardon answered 20/10, 2016 at 23:16 Comment(0)
D
1

I had a very similar issue and removing the following from my build.gradle fixed it. The same bit of config works in all other Gradle projects I have but for some reason not this one...

allprojects {
    ...
    apply plugin: 'eclipse-wtp'
    ...
    // remove this eclipse config to make the error go away
    eclipse {
        classpath { defaultOutputDir = file('build-eclipse') }
    }
    ...
}
Disobedient answered 22/1, 2018 at 14:22 Comment(0)
M
1

I ran into a similar issue recently - even blowing away the project and repulling a fresh copy from git didn't fix it. I realized it wasn't specific to the project when I reproduced it outside of Eclipse:

$ ./gradlew tasks

FAILURE: Build failed with an exception.

* What went wrong:
Expecting a stack map frame
Exception Details:
  Location:
    build_euvk0e0guiuwrf8fgn8svi2fy.run()Ljava/lang/Object; @16: aconst_null
  Reason:
    Error exists in the bytecode
  Bytecode:
    0x0000000: 2abb 0022 592a 2ab7 0025 ba00 3300 00b0
    0x0000010: 01b0                                   

What did fix it was removing the gradle cache:

$ rm -r ~/.gradle/caches 
$ ./gradlew tasks

Somehow the version of gradle there had become corrupted (possibly related to Eclipse groovy plugin - I had this issue regularly until uninstalling it), and blowing it away forced it to get a fresh copy.

Hopefully this answer helps someone else avoid pulling out their hair.

Mazard answered 20/3, 2018 at 21:29 Comment(0)
D
0

Open the CMD and enter there gradle --gui, change the settings of the gradle gui in the register Setup to Stack trace Output: Full Stack trace [-S] and the log level to info. Then change the current directory to the directory your build.gradle file is located and then go to the first register and let process the gui this files.

An error message should be displayed. There you find out what is wrong with your build.gradle file. In my case there was a folder missing and this causes this error.

Duron answered 11/6, 2016 at 18:52 Comment(0)
B
0

This error can also be caused by a syntax error in the previous line of build.gradle. If so, the error has nothing to do with the Gradle or Eclipse version you are running. See this question

Browbeat answered 23/6, 2017 at 15:47 Comment(0)
A
0

In my case i changed the Gradle version from 4.7.rc2 to4.6 and then it started to work.

Atherosclerosis answered 13/4, 2018 at 20:10 Comment(0)
O
0

I am on eclipse Oxygen (4.7.2), I was getting similar exception while importing the project and this worked for me:

  • While importing on windows Import Options
  • Click Configure Workspace Setting (which will take to preference window)
  • Select Local Installation directory (for me 'graddle wrapper' was selected)
  • apply, close and continue import

Below is the error I was getting

Loading Gradle project preview failed due to an error in the referenced Gradle build.
Could not fetch model of type 'GradleBuild' using Gradle distribution 'https://services.gradle.org/distributions/gradle-3.5-bin.zip'.

_BuildScript_
org.gradle.tooling.BuildException: Could not fetch model of type 'GradleBuild' using Gradle distribution 'https://services.gradle.org/distributions/gradle-3.5-bin.zip'.
    at org.gradle.tooling.internal.consumer.ExceptionTransformer.transform(ExceptionTransformer.java:51)
    at org.gradle.tooling.internal.consumer.ExceptionTransformer.transform(ExceptionTransformer.java:29)
    at org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.java:41)
    at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:57)
    at Caused by: java.lang.ClassNotFoundException: _BuildScript_
    at org.gradle.groovy.scripts.internal.DefaultScriptCompilationHandler$ScriptClassLoader.loadClass(DefaultScriptCompilationHandler.java:386)
    ... 77 more


Okwu answered 4/4, 2019 at 21:44 Comment(0)
E
0

None of the solutions worked for me and I'm having the same errors on STS 4 with eclipse Version: 2.2.600.v20190605-1800. My steps were:

  1. Delete the project from my workspace
  2. ./gradlew cleanEclipseWtp cleanEclipse eclipseWtp eclipse

  3. Import the project as an existing eclipse project (not an existing gradle import)

That worked!

Electrometer answered 7/9, 2019 at 0:18 Comment(0)
P
0

Deleting .gradle folder from the project resolved my problem.

Papaya answered 20/12, 2019 at 5:42 Comment(0)
L
0

I got this error with Eclipse 2021-06, Java 1.8.0, gradle 4.4. I tried deleting gradle wrapper binary folder, predefining gradle version, etc.

The thing that helped was just specifying gradle home directory and java home directory after selecting overriding workspace configuration.

Launalaunce answered 15/9, 2021 at 12:53 Comment(0)
P
0

I got the problem resolved by upading the artifactoryUsername and artifactoryPassword in gradle.properties.

username = artifactoryUsername
password = artifactoryPassword
Partan answered 17/5, 2024 at 9:39 Comment(0)
U
-2

Eclipse 4.4.1 broke Gradle Eclipse support with non-string values in system properties.This is fixed in the latest Gradle for the 3.6.2 release. Update your Gradle form this update-site: http://dist.springsource.com/snapshot/TOOLS/gradle/nightly

Unbutton answered 10/10, 2014 at 13:51 Comment(3)
Both the Gradle version number and the link you reference don't exist.Bombacaceous
I guess you mean not version 3.6.2 of Gradle (the newest is currently 2.13), but 3.6.2 (or newer) of the Gradle IDE? Unfortunately this also happends with Gradle IDE 3.7.3, on Eclipse 4.5.2.Demagogic
Gradle 4.4.1 from Dec 2017 has the same problem still.Impignorate

© 2022 - 2025 — McMap. All rights reserved.