Eclipse Gradle project shows dependency errors : the container 'project and external dependencies' references non existing library

Viewed 6407

Eclipse Gradle project shows dependency errors.

the container 'project and external dependencies' references non existing library

5 Answers

Got the same error. Gradle -> Refresh Project.. did not fix it.

Close Project, then Open Project did fix it.

Eclipse Gradle projects have a button to refresh the gradle project, but it is not really obvious and does not trigger when trying to 'quick fix' the error in eclipse.

  • Right-click on the desired Project that has dependency errors
  • In the menu select Gradle
  • Click 'Refresh Gradle Project'

This will remove the errors but could take a few minutes to process.

If the errors are still present in eclipse you should try to refresh dependencies and build with gradle outside of eclipse on the command line and see if that works to rule out eclipse/gradle sync as your issue.

Example of gradle command line to refresh and build (use gradlew if your using a gradle wrapper):

gradle clean
gradle --refresh-dependencies
gradle build -x test
gradle test (optional)

I get this same error. It happens randomly every now and then, to most projects I have imported into Eclipse. Gradle misses some random dependency even though it's on the disc. Below image shows 6 different projects failing and next picture shows none-existing library reference actually exists. enter image description here.
enter image description here

A Gradle refresh usually does not solve it. To solve it I have to delete the project from Eclipse (not disc), then manually remove .classpath/.project files and .settings folder, then import project into Eclipse again. Very annoying :/

Based upon the feedback from the other answers, you probably should file an issue against Buildship, as this seems easy to reproduce. However, there already is one issue #985 filed, which states that the reason would / might be a read-only .classpath or .project files.

I tried all the suggestions above. Unfortunately, none of those steps helped me.

On Mac, this is what I had to do...

$ brew upgrade gradle  
   (this upgraded gradle from 5.0 to 6.7.1)...
$ cd /project_root
$ gradle help --scan
$ gradle wrapper --gradle-version 6.7.1
Related