Question

I created a new xml file, and had an errant ? in it that prevented R.java from regenerating. I tried Cleaning the Project, and Fixing the Project Properties but no luck.

Then I realized the XML was creating the R.java from recreating itself, so I deleted the XML file and the R.java was back.

Now though, I am getting an error on all the calls to R.. calls saying that :

  • cannot be resolved or is not a field

So, for instance I have

setContentView(R.layout.detectlayout);

ERROR: detectlayout cannot be resolved or is not a field

for all of my calls to 'R.'. Any ideas?

I have tried all of the suggestions on SO already to no luck =/

Was it helpful?

Solution

Look at the 'import' section of your code. Since you deleted your original R, chances is Eclipse help you to fill in the R as com.android.R instead of com.yourproject.R

I also sometimes have problem in Eclipse Resource stuff, sometimes I found turning off and on the "auto buiild" function may help, or simply restarting Eclipse may sometimes help. It's kind of buggy under Mac OS.

OTHER TIPS

This can happen if .R is imported. Eclipse will automatically add it sometimes when you have difficulty with with R.java

first don't bother deleting the R file it not going to make things better only worst lol

as you said you some times need to clean the project when you start modifying resources its good to select the root of your project and do a alt+shift+o to reload all ressources then f5 to refresh the tree then clean the project

you also have to check that eclipse is set to build automatically (Project->build automatically).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top