Eclipse Gradle 插件“无法获取类型的模型”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26281466/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 05:25:33  来源:igfitidea点击:

Eclipse Gradle Plugin 'could not fetch model of type'

eclipsegradlegradle-eclipse

提问by Michael

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:

我在 OS X 上使用 Gradle IDE 3.6.1 运行 Eclipse Luna,每当我尝试从 gradle 任务面板中选择一个项目时,我都会收到以下错误:

org.eclipse.osgi.internal.framework.EquinoxConfiguration
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.

有没有其他人遇到过这个错误?我可以访问指定的 URL 以自己下载文件。因此,网络连接应该不是问题。

采纳答案by aboyko

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

Eclipse 4.4.1 打破了 Gradle Eclipse 对系统属性中非字符串值的支持。这在 3.6.2 版本的最新 Gradle 中得到了修复。从这个更新站点更新你的 Gradle:http: //dist.springsource.com/snapshot/TOOLS/gradle/nightly

回答by Josh Davis

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.

我在 Eclipse Neon 中遇到了同样的错误(版本号不同,但其他方面的错误相同)。看起来有几种不同的事情会导致这个错误,但对我来说,这是 [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.

2.13 应该替换为您从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.

回来补充一点:事实证明,实际的根本问题是 Gradle 版本之间的不兼容。我的 build.gradle 文件在旧版本的 Gradle 上运行良好,但使用了在更高版本中被弃用和删除的内容。

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

解决方案是在向导中立即单击完成而不是下一步,然后修复 build.gradle 中的问题。

回答by Dushyant Patel

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.

它发生的原因,导致可以下载新版本的 gradle。一旦你下载了新版本的 gradle,你的错误就会消失。

http://gradle.org/downloads

http://gradle.org/downloads

回答by Sergey Nikishchenko

Bad reference in config.

配置中的错误参考。

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

覆盖配置:
项目 -> 属性 -> Gradle -> 覆盖工作区设置 ->
特定 Gradle 版本 -> 4.x

回答by Tim VanDoren

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

我有一个非常相似的问题,从我的 build.gradle 中删除以下内容修复了它。同样的配置适用于我拥有的所有其他 Gradle 项目,但由于某种原因不是这个......

allprojects {
    ...
    apply plugin: 'eclipse-wtp'
    ...
    // remove this eclipse config to make the error go away
    eclipse {
        classpath { defaultOutputDir = file('build-eclipse') }
    }
    ...
}

回答by Krease

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:

我最近遇到了一个类似的问题 - 即使取消了项目并从 git 中删除了一个新副本也没有解决它。当我在 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 didfix it was removing the gradle cache:

什么修复它被移除缓存的gradle:

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

不知何故,那里的 gradle 版本已损坏(可能与 Eclipse groovy 插件有关 - 在卸载它之前我经常遇到这个问题),并且将其吹走迫使它获得一个新副本。

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

希望这个答案可以帮助其他人避免拔头发。

回答by Dhiren Solanki

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

您需要更新 Gradle Goto:选择“帮助 > 关于 Eclipse”(在 Mac 上,这是“Eclipse > 关于 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.

搜索 Gradle(用于 Gradle 的 Eclipse 插件)并更新。

It might take some time for first time after that.

之后第一次可能需要一些时间。

回答by Chris

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 4.5 有相同的错误消息在我的情况下,构建文件有错误,我不得不修改这一行

eclipse.classpath  {
    plusConfigurations += configurations.providedCompile
}

into this

进入这个

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

After that everything worked again.

在那之后,一切又恢复了。

回答by taozhang

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:

我遇到了同样的问题,有人建议 gradle 项目可能是由旧版本构建的。我通过以下步骤解决问题:

  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
  1. 修改Eclipse中的配置, perfrence ->gradle ->gradle distribution 。将其指向旧版本。
  2. 删除 ./gradle/wrapper 中的文件
  3. 重新加载程序

回答by Kris Swat

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

就我而言,我忘记将结尾撇号 ' 作为值

回答by geneSummons

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

此错误也可能是由 build.gradle 前一行中的语法错误引起的。如果是这样,则该错误与您运行的 Gradle 或 Eclipse 版本无关。看到这个问题