Every time in code that I have an R, I get an error R cannot be resolved to a variable.
The R.java file appears to be missing.
I have tried cleaning the proj
Check your XML resources (especially these recently edited) for mistakes and sytax errors. When you have an error inside one of these files, the R class autogeneration will abort.
This happened in my case as a image that was present in res/drawable-hdpi had a capital character, I made it small then it worked.
This is a very common issue, this is encountered when we edit any of the xml file in our project like drawable, layout, strings etc.
We usually clean project (or) restart our IDE (or) import R.java when we get this problem. Never do import.
First try to fix the errors in all xml files and then remove the R.java import from java files. And then clean the project.
So simple.
This happened to me because of a bad resource name (some audio file had " - " in a name), I fixed it by renaming the file.
Check if you accidentally imported android.R
, this gives an error with resources as well.
Ah, the "R cannot be resolved" error. I think every Android programmer has run across this sometime or the other. I wish the tools were more robust about generation of R.java & class.
Try this, it has worked for me in past:
Right-click on the Project root --> Android Tools --> Fix Project Properties