This question already has an answer here:
In Eclipse, I've created a project from a source and now it shows errors - "R cannot be resolved to a variable". From what I found here, I had cleared and rebuilt the project, but still the R file doesn't appear in the /gen folder.
Any ideas?
Dont worry. First you may clean the project, then run the project. If this does not work then follow the following links:
Remove any XML files in the /res/menu folder.
I been having this and i did trace it back to the layout files.. It happend to me again however i could not find noting in the layout files. I looked in the string.xml and there was it.. one of the string names started with cap and that was causing the problem.
In my case, R.java wasn't getting generated because of a hierarchical parent error, which in turn was cured by updated one or more Eclipse plugins (Go Eclipse-->Help-->Check for Updates)
for me, the best solution to suggest to people that have problems with the "R" file would be to try the next steps (order doesn't matter) :
update ADT & SDK , Eclipse and Java.
remove gen folder , and create it again .
do a clean-project.
right click the project and choose android-tools -> fix-project-properties .
right click the project and choose properties -> java-build-path -> order-and-export. make sure the order is :
Android 4.3 (always the latest version)
Android private libraries
android dependencies
your library project/s if needed
yourAppProject/gen
yourAppProject/src
make sure all files in the res folder's subfolders have names that are ok : only lowercase letters, digits and underscore ("_") .
always make sure the targetSdk is pointed to the latest API (currently 18) , and set it in the project.properties file
This can happen when the android naming convention isn't followed. Check if you have placed a file/photo into one of the android folders and make sure that the file name contains only lower case letters