R cannot be resolved to a variable error?


#1

How to fix this error when fist run and r.java file is not generated?
Tried to clean and build in eclipse but not working?
“R cannot be resolved to a variable”


#2

If cleaning and rebuilding doesn’t cause the R class file to be generated, then check for errors in any of the .xml file under the res folder, especially any of the layout files. If any errors are present in any of the resource files, then the R file will not be generated regardless of how many times you clean and rebuild your project.