"R cannot be resolved to a variable"? [duplicate] "R cannot be resolved to a variable"? [duplicate] android android

"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:


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.

Screenshot of Android SDK Manager after fixing the problem
Cheers, Mayank