During Android development, the error message "r cannot be resolved to a variable" appears to be unknown. Generally, I have summarized several possible solutions, I hope it will work in the future...
1. Check whether the android SDK is lost and re-download it. Check the build path.
2. Make sure that the class does not have import Android. R;
3. the XML file of layout referenced by the error class is not incorrect.
4. Check that all the strings in the androidmanifest. xml file, package, layout configuration file, and strings. XML are correctly written.
5. The strings referenced in strings. XML in the XML file of layout are spelled correctly.
6. add a control manually in the XML file of layout to check whether the ID can be in the R. automatically Generated in Java. If not, it is very likely that the layout XML file has a problem. Check whether the format is correct or what illegal string is contained, or an incorrect string is called. You can use exclusion to remove the control one by one until the error message disappears or the ID can be in the R. automatically Generated in Java.
7. Delete the gen folder so that R. Java can be automatically generated again. If not, continue to check whether the XML file of layout is as hard to detect.
8. Clean Project, re-build, or re-import project.
9. Restart eclipse
10. Restart your computer to prevent problems with the android virtual machine.
If it doesn't work any more, you'll have to look for other places.