Solution for: Error: R cannot be resolved to a variable


Problem:

Error: R cannot be resolved to a variable

Solutions:

1. check to see if there is an error in the androidmanifest.xml file. (like two <application> tags. (there should only be one, delete one). If you delete a project, and create it again, with the same name, this may happen. (normally you delete the 2nd set)

2. make sure import android.R;
is NOT in the .java file

3. If you run select "Project" -> "Clean..." on the Eclipse menu, it will remove and then regenerate the R.javafile.