Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Unable to open class file R.java [duplicate]

Did a fresh install of Eclipse, JDK and android-sdk.

I am currently receiving this error when creating a new project

[2010-09-26 16:07:56 - Test] ERROR: Unable to open class file C:\workspace\Test\gen\com\example\test\R.java: No such file or directory

What's the reason for this and how do I fix it?

Eclipse Helios 32 bit
java version "1.6.0_21"
Android sdk API 8

P.S. I'm new to Android development.

EDIT: I tried most of your solutions, but nothing worked. So I started using my friend's install of Eclipse Ganymede.

like image 901
Croydon Dias Avatar asked Sep 26 '10 03:09

Croydon Dias


3 Answers

I have had same issue, all what I needed to do, was create project and restart eclipse.

//Edit: Complete collapsing of "Package" tree works as well.

like image 77
Ency Avatar answered Oct 22 '22 02:10

Ency


This is a mighty annoying error.

It happens 100% of the time when I create a new android project.

What seems to work for me is to just delete the file (which DOES exist and is accessible by my user), then hit build, and it will regenerate it and stop moaning.

It's clearly a bug as there are too many people getting it simply by filling in the boxes in the new project dialog (like me) without even modifying any code!

like image 14
Sam Bartle Avatar answered Oct 22 '22 04:10

Sam Bartle


Have a look at your console. It is an aapt aborted error. Since aapt is the tool that auto-generates R.java, therefore, R.java was not getting generated.

Since R.java is a auto-generated file that stores information about your drawables you should rebuild your project. Before that have a look at your layout xml files and check them for errors.

Notice that Project -> Build All should be selected. Also try to run your project.

like image 12
UpCat Avatar answered Oct 22 '22 03:10

UpCat