views:

379

answers:

1

Hi i have erorr "R cannot be resolved" everytime when i create android project in eclipse under ubuntu with android sdk. In windows everything ok. What's wrong?

A: 

R is a Java class created in source form by the build process. It contains definitions of locally unique numbers to refer to the assets under your project's 'res' directory.

See if you have a 'gen' folder in the route of your Eclipse project. Then look in this folder and see if you have R.java class under a package structure representing the same as the 'package' attribute in the manifest tag in your AndroidManifest.xml.

There is a common problem where the 'gen' folder gets deleted by Project->Clean, or where a project is copied from one workstation to another it seems sometimes the 'gen' folder does not get generated. You could try making a 'gen' folder of your own in your project root to see if this fixes it.

If you are referring to this file from a Java file with a package different to this you will have to explicitly 'import' it, but Eclipse should prompt you with assistance about this.

Jim Blackler
Hmm i have gen folder and R.java file.
Smain
OK, when you type 'R' in the file, does Eclipse suggest an import for you?
Jim Blackler
Nope, i type R and nothing happens
Smain