eclipse 如何修复 Buildship 中的“缺少 Gradle 项目配置文件”问题?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42393545/
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
How to fix "Missing Gradle project configuration file" issue in Buildship?
提问by Alan47
As an Eclipse user, I always liked the Gradle IDE. However, this plugin is now deprecated in favor of the new Buildship plugin.
作为 Eclipse 用户,我一直喜欢 Gradle IDE。然而,这个插件现在已被弃用,取而代之的是新的 Buildship 插件。
After setting up a fresh Eclipse IDE with Buildship installed, I'm faced with the following error in all my Gradle projects:
在安装了 Buildship 的情况下设置新的 Eclipse IDE 后,我在所有 Gradle 项目中都面临以下错误:
missing gradle project configuration file: .settings/org.eclipse.buildship.core.prefs
缺少 gradle 项目配置文件:.settings/org.eclipse.buildship.core.prefs
There are several pages on google that deal with this issue, but all of them seem pretty outdated. There is also an entry in the bugtracker of the plugin which is set to "CLOSED FIXED". Well, apparently, it's not fixed.
谷歌上有几个页面处理这个问题,但它们似乎都已经过时了。插件的错误跟踪器中还有一个条目设置为“已关闭”。嗯,显然,它没有固定。
Am I doing something wrong? Any ideas how to tackle this issue?
难道我做错了什么?任何想法如何解决这个问题?
回答by Alan47
I've figured it out myself. The issue with the "missing gradle project configuration file" arises from the way the gradle project(s) are imported into Eclipse.
我自己想通了。“缺少 gradle 项目配置文件”的问题源于将 gradle 项目导入 Eclipse 的方式。
When importing a gradle project via the regular File -> Import -> General -> Existing Project into Workspace
command, then it will notworkand produce the aforementioned error.
当通过定期导入gradle这个项目File -> Import -> General -> Existing Project into Workspace
的命令,那么它将无法正常工作,并产生上述错误。
However, if you import the very same project via File -> Import -> Gradle -> Existing Gradle Project
, then you get a differentimport wizard, and with this wizard, it works like a charm.
但是,如果您通过 导入完全相同的项目File -> Import -> Gradle -> Existing Gradle Project
,那么您将获得一个不同的导入向导,并且使用该向导,它的工作就像一个魅力。
I still think it's a bug because the choice of the import wizard should not matter. Still, choosing the proper wizard is a viable workaround.
我仍然认为这是一个错误,因为导入向导的选择无关紧要。尽管如此,选择合适的向导仍然是一个可行的解决方法。
回答by SWiggels
Another option is to:
另一种选择是:
- Move to your projects path (where gradle or gradlew is found)
- Unix:
sh gradlew cleaneclipse
Win:gradlew cleaneclipse
- 移动到您的项目路径(找到 gradle 或 gradlew 的位置)
- Unix:
sh gradlew cleaneclipse
赢:gradlew cleaneclipse
Requires the apply plugin: 'eclipse'
in your build.gradle
需要apply plugin: 'eclipse'
在您的build.gradle
- Refresh your Project in eclipse.
- After that for Unix:
sh gradlew eclipse
Win:gradlew eclipse
- 在 Eclipse 中刷新您的项目。
- 之后对于 Unix:
sh gradlew eclipse
Win:gradlew eclipse
Now the gradle nature will be missing in your eclipse-project. Open the context menu of your project -> configure -> add gradle nature
现在,您的 eclipse 项目中将缺少 gradle 性质。打开您的上下文菜单project -> configure -> add gradle nature
Now everything should be fine again.
现在一切都应该好了。
回答by Danielson Alves Júnior
I seriously searched for the solution, but only found workarounds. Alan47's solution created the file for me, but couldn't create the project properly in my case. So I just copied the file created and imported the project again in the default way:
我认真地寻找解决方案,但只找到了解决方法。Alan47 的解决方案为我创建了文件,但在我的情况下无法正确创建项目。所以我只是复制了创建的文件并以默认方式再次导入了项目:
File -> Import -> General -> Existing Project into Workspace
and pasted the file again at the directory
并将文件再次粘贴到目录中
./.settings
The name of the file:
文件名:
org.eclipse.buildship.core.prefs
The content of the file is only:
该文件的内容仅为:
connection.project.dir=
eclipse.preferences.version=1
回答by Marian
The easiest solution, using just the mouse
最简单的解决方案,只使用鼠标
As is told here by oehme (Stefan Oehme - core dev):
https://github.com/eclipse/buildship/issues/504
正如 oehme (Stefan Oehme - 核心开发人员) 所说:https:
//github.com/eclipse/buildship/issues/504
"Buildship can't recreate that file as it cannot know what your root project was (Gradle supports arbitrary project layouts). You should either check the settings file in or not check in any Eclipse files at all. Checking in .project while leaving out .settings is not supported."
“Buildship 无法重新创建该文件,因为它无法知道您的根项目是什么(Gradle 支持任意项目布局)。您应该检入设置文件或根本不检入任何 Eclipse 文件。检入 .project 而忽略.settings 不受支持。”
Or here (Stefan Oehme - core dev):
https://discuss.gradle.org/t/do-i-need-to-check-in-settings-org-eclipse-buildship-core-prefs-file/22457/2:
或者在这里(Stefan Oehme - 核心开发):
https://discuss.gradle.org/t/do-i-need-to-check-in-settings-org-eclipse-buildship-core-prefs-file/22457/ 2:
"This would happen if you have a checked in .project file with the buildship nature, but no checked in settings file. The choice is between checking in both or checking in neither and using the Gradle import wizard."
“如果您已签入具有构建性质的 .project 文件,但没有签入设置文件,则会发生这种情况。选择是在两者都签入或两者都不签入和使用 Gradle 导入向导之间。”
The easiest solution, using just the mouseis the following:
仅使用鼠标的最简单解决方案如下:
- Right click on the project then click Properties
- In the properties window go to the Project Naturesand removethe Gradle Naturethen click Apply and Close button
- Open again the same window and add Gradle Nature back, then click Apply and Closebutton
- Right Click on the project > Gradle > Refresh Gradle project
- 右键单击项目,然后单击属性
- 在属性窗口中去的项目性质和去除的摇篮自然然后单击应用和关闭按钮
- 再次打开同一个窗口并重新添加 Gradle Nature,然后单击Apply 和 Close按钮
- 右键单击项目 > Gradle >刷新 Gradle 项目
After each step: 1,2,3,4 let eclipse do its update job, do not push it quickly.
在每一步之后:1,2,3,4 让 eclipse 做它的更新工作,不要快速推送。
Other solution is to have the file saved somewhere and paste it again in the project or create from scratch manually, then do: Right Click on the project > Gradle > Refresh Gradle project.
其他解决方案是将文件保存在某处并将其再次粘贴到项目中或手动从头开始创建,然后执行以下操作:右键单击项目 > Gradle > Refresh Gradle 项目。
Useful details:
有用的细节:
File name: org.eclipse.buildship.core.prefs
File usual encoding: ISO_8859_1
File path: ./setting/org.eclipse.buildship.core.prefs
File content, one line: connection.project.dir = eclipse.preferences.version=1
文件名:org.eclipse.buildship.core.prefs
文件常用编码:ISO_8859_1
文件路径:./setting/org.eclipse.buildship.core.prefs
文件内容,一行:connection.project.dir = eclipse.preferences.version =1
回答by Aris jirat kurniawan
maybe you can use this method. by making the file back
也许你可以使用这个方法。通过恢复文件
I accidentally deleted or lost the file in my flutter project.
我不小心删除或丢失了我的颤振项目中的文件。
then I make a new method
enter the ./android
folder in your flutter project.
copy to your terminal for mac:
然后我创建了一个新方法进入./android
你的颤振项目中的文件夹。复制到你的 Mac 终端:
touch "org.eclipse.buildship.core.prefs"; echo "connection.project.dir=
eclipse.preferences.version=1" >> org.eclipse.buildship.core.prefs
then to your ./android/app
folder in your flutter project.
然后到您./android/app
的颤振项目中的文件夹。
touch "org.eclipse.buildship.core.prefs"; echo "connection.project.dir=..
eclipse.preferences.version=1" >> org.eclipse.buildship.core.prefs