"R cannot be resolved to a variable"? [duplicate]
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?
Solution 1:
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
Solution 2:
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.
Solution 3:
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
Solution 4:
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