I created a Hello world app but get this strange error:
The project cannot be built until the build path errors are resolved
I haven't changed the project, jut created it and tried to run it.
to avoid that annoying problem i have 3 solutions that worked for me.
Solution 1)
delete your generated R.java file inside your gen/ folder
Solution 2)
a)Delete your project from Eclipse (i said ONLY from Eclipse, uncheck option: Delete project contents on disk)
b) import your project to Eclipse: file > Import > Existing Projects into Workspace (Look for your project previously deleted from Eclipse) > Finish.
Solution 3)
make Solution 1 then Solution 2
It is either a spurious message you can solve by forcing Eclipse to recompute its library paths
I found the resolution for this at Scott D. Strader's blog.
To summarize the solution I only needed to add a library to my project and then remove it to force Eclipse to perform the necessary actions to resolve the problem. I would post the detailed steps here but I don't want to steal his content.The resolution was to force a resave of the selected projects (and their
.classpath
files):
- Open the project properties
- Select Java Build Path > Libraries
- Add a new, arbitrary library (to be deleted later) > OK
- Wait for the workspace to refresh (or force a refresh of the project)
- The error(s) will go away
- Remove the dummy library
Note: as the OP mentions, a simple restart of the IDE can be enough.
Or you actually miss one critical library like a JRE library:
I needed to add the JRE library to the project for it to run. Not sure if this was due to the updated version or something else…. Any way this fixed the issue:
- Project > Properties
- Java Build Path
- Libraries tab
- Click add library
- Select JRE System Library
- Next
- Finish
Sounds like you are missing an import or a jar. In your project in the project explorer there should be a red x on the file icon that contains the error.
In addition to the listed answers, there is one other scenario I've seen this error appear when using the sample projects included with the Android SDK. For some reason, the generated R.java file can be invalid or corrupt. You can get around it by expanding the "gen" folder in the Package Explorer and deleting the R.java file. It will immediately get regenerated and the error goes away.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With