Ian Vink
Ian Vink

Reputation: 68740

Eclipse - HelloWorld - Android error?

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.

Upvotes: 5

Views: 1802

Answers (6)

Robert de Klerk
Robert de Klerk

Reputation: 624

I have had similar issues. for me simply closing the emulator and re-running the project works

Upvotes: 0

Jorgesys
Jorgesys

Reputation: 126445

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

Upvotes: 2

Curtain
Curtain

Reputation: 1972

Right click on your project, choose "Build Path", "Configure Build Path" -> and choose Android 2.2, or that target you specified when you created your project

Upvotes: 1

Nate Dudek
Nate Dudek

Reputation: 1265

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.

Upvotes: 1

VonC
VonC

Reputation: 1323115

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

Upvotes: 2

Robby Pond
Robby Pond

Reputation: 73484

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.

Upvotes: 1

Related Questions