Android: R cannot be resolved to a variable

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.