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?
If Clean/Rebuild Project doesn't work try to check our package name in AndroidManifest.xml.
The problem "R cannot be resolved" happens when you change your package name in the AndroidManifest.xml file. It uses your Android package name to create a subdirectory under the "gen" directory where it stores the R.java file.
It is possible you have an error in your *.xml files: layouts and etc.
Did you just update both sdk and adt(from 21 to 22), then you need to install a new item: Android SDK Build-tools
Refer to: Eclipse giving error, missing R.java file after recent update
your android manifest must start with correct package
I solved the problem with resolving R resource on fc19.x86_64 and ADT v22.0.5-757759 by installing additional libraries after Fedora and ADT upgrade.
Those libraries are required by adb (Android Debug Bridge version 1.0.31).
Then restart Eclipse and perform project clean Project->Clean check project you would like to clean.
Hope it helps :)
Problem was eclipse was not generating R.java. To resolve this issue please go to project->clean... and select your project and select ok and then clean and build project and import your package name R file(Ex com.demo.R). It works.