问题
As an Eclipse user, I always liked the Gradle IDE. However, this plugin is now deprecated in favor of the new Buildship plugin.
After setting up a fresh Eclipse IDE with Buildship installed, I'm faced with the following error in all my Gradle projects:
missing gradle project configuration file: .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?
回答1:
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.
When importing a gradle project via the regular File -> Import -> General -> Existing Project into Workspace
command, then it will not work and produce the aforementioned error.
However, if you import the very same project via File -> Import -> Gradle -> Existing Gradle Project
, then you get a different import wizard, and with this wizard, it works like a charm.
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.
回答2:
Another option is to:
- Move to your projects path (where gradle or gradlew is found)
- Unix:
sh gradlew cleaneclipse
Win:gradlew cleaneclipse
Requires the apply plugin: 'eclipse'
in your build.gradle
- Refresh your Project in eclipse.
- After that for 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
Now everything should be fine again.
回答3:
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:
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
回答4:
The easiest solution, using just the mouse
As is told here by oehme (Stefan Oehme - core dev):
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."
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:
"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."
The easiest solution, using just the mouse is the following:
- Right click on the project then click Properties
- In the properties window go to the Project Natures and remove the Gradle Nature then click Apply and Close button
- Open again the same window and add Gradle Nature back, then click Apply and Close button
- Right Click on the project > Gradle > Refresh Gradle project
After each step: 1,2,3,4 let eclipse do its update job, do not push it quickly.
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.
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
回答5:
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:
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.
touch "org.eclipse.buildship.core.prefs"; echo "connection.project.dir=..
eclipse.preferences.version=1" >> org.eclipse.buildship.core.prefs
来源:https://stackoverflow.com/questions/42393545/how-to-fix-missing-gradle-project-configuration-file-issue-in-buildship