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.