LuxuryMode
LuxuryMode

Reputation: 33741

Error: Unable to fnd class R.java No such file or dir

I keep getting this when trying to start a new project

ERROR: Unable to open class file C:\Users\Levi\Desktop\Android\workspace\Droid1\gen\com\androidbook\droid1\R.java: No such file or directory

I tried changing preferences to alter build path to project, but it still wouldnt work,,,

Is subfolder on desktop a bad place to install Eclipse?

Upvotes: 4

Views: 6719

Answers (5)

Lenn Dolling
Lenn Dolling

Reputation: 1300

after spending hours trying to ultimatly discover the issue behind the Class Issue not being found, resolved,or directory not there issue....

sometimes yes the issue is due to a bad binary or xml... as sometime a clean will do the trick or a xml edit will solve the day.. when all else fails.... this may do it..

"create a new workspace"

go into the workspace.... and then

Switch to your old workspace... in the newly formed workspace...

this was my silver bullet. so frustrating to not have a solid answer.

using Version: Helios Service Release 2 Build id: 20110218-0911

Upvotes: 0

Martin
Martin

Reputation: 1163

Usually, the above tips (refresh, clean) work for me. But lately I had a very persistant instance of this error, which was caused by something else:

One of the layout .xml files in res/layout contained a reference to a custom view (org.company.project1.MyView). However, I had changed the package path (org.company.project2.MyView), so the reference had become invalid.

Thus, if everything fails try browsing your layout .xml files for invalid custom element definitions.

Cheers

Upvotes: 2

Gray
Gray

Reputation: 116908

Clean works sometimes and should be tried. I also find that blowing away the gen directory and refreshing will cause it be to rebuilt. Try that as well.

However, sometimes even that doesn't work and I've been forced to remove the project from Eclipse and then re-import it. This, unfortunately, works for me every time if the above has not.

Good luck.

Upvotes: 5

Reuben Scratton
Reuben Scratton

Reputation: 38717

Project->Clean should certainly fix this (unless your resources won't compile for some seperate reason).

I remember that the first time I ran Eclipse (in mid 2009, can't remember if it was Galileo or Ganymede or whatever) on Windows Vista, it presented several problems that were eventually traced to Eclipse itself being in a directory whose path contained a space...

Upvotes: 2

Mads Lee Jensen
Mads Lee Jensen

Reputation: 4658

Im also getting that error, running a Project->Clean in Eclipse helps for me.

Upvotes: 2

Related Questions