Solutions for Unable to generate r files under Gen files in Android project

Source: Internet
Author: User

Help a netizen to solve the problem of the R file can not be generated, collected some materials special finishing as follows, beginners refer to others code is very easy to appear this kind of problem, is generally an XML file error, can not be correctly parsed.

The Gen directory could not be updated, or the R.java file in the Gen directory could not be generated

1, the use of the Gen directory

The Android Gen Directory R.java is not created by the user, but the Android project itself automatically "numbers" (ID) values for Android resources.

2. Why r files cannot be updated/generated in Gen directory

1) There is an error in the XML file name under Layout in the Res directory.  The following Android naming conventions are: [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 inside the existence of illegal characters, generally under eclipse will be prompted, if you find a hit x, you need to modify. Special note is the half-width symbol and the full-width symbol, this error is very covert, we must be careful. There are also write specifications that conform to XML.

3) The name of the control's ID value is duplicated in the XML file under Layout. This mistake is very covert, we must examine it carefully. Because eclipse itself does not make an error.

3. Solutions

If the above reasons are found, this time the Gen directory R still error, the Android project to refresh, to see if the R file has been updated. You can also tick project->build automatically to let Eclipse help you with Automatic Updates.

If it doesn't work, try to clean it and see if it will be automatically generated.

If the above reasons are found, but the source code is still wrong, this time you look at, import Android. R This package has been introduced, if it is 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.