The solution to the R file cannot be generated in the Gen file under the Android project

Source: Internet
Author: User

Help a netizen to solve the problem of the R file can not be generated, collected some materials, such as the following, the people who have just started to study the code of others is very prone to this problem, generally is an XML file error, can not be parsed correctly.

The Gen folder cannot be updated, or the R.java file under the Gen folder cannot be generated

1. Use of the Gen folder

The R.java in the Android Gen folder is not created by the user, but rather the androidproject itself makes the Android resource its own active "number" (ID) value.

2. Why r files cannot be updated/generated under Gen folder

1) There is an error in the XML file name under Layout in the Res folder.  According to the Android naming convention is: [A-z0-9_.] Here to see clearly, can not capitalize the beginning! Causes XML to not be parsed correctly.

2) in the layout of the XML file in the presence of illegal characters, generally under eclipse will be prompted, assuming that there is a hit x, you need to change. Special note is the half-width symbol and the full-width symbol, this error is very hidden, we have to be careful. There are also write specifications that conform to XML.

3) in the XML file under Layout, the ID value of the control is named repeatedly. This error is very covert, we must examine it carefully. Since eclipse itself does not make an error.

3, the way to solve

Assuming the above reasons are found, this time the Gen folder R still error, the Android project to refresh, to see if the R file has been updated. You can also check the project->build automatically to let Eclipse help you proactively update yourself.

If it doesn't work, try to clean it and see if it will be normal for you to generate it yourself.

Assuming the above reasons are found, but the source is still wrong, this time you look at, import Android. R whether the package has been introduced, if included, please remove the package, or the error cannot be lifted.

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.