"R cannot be resolved to a variable"? [duplicate]
Dont worry. First you may clean the project, then run the project. If this does not work then follow the following links:
- Here is the best way to solve this problem: [Android Development- Where is my R.Java file?][2]
- R.java not regenerating
- R cannot be resolved - Android error
- R cannot be resolved to a variable
- R cannot be resolved to a variable -- mailing list entry
- Fixed: R cannot be resolved to a variable
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.
For me the error got fixed by making some changes in Android SDK Manager.
Whatever be the latest API level available, install its "SDK Platform". For me latest API level available was 16, so I installed its's SDK Platform as shown in the image below. It works fine now.
Cheers, Mayank