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

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


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.


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!


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.