Android Learning--r File Loss Exception Reason summary

Source: Internet
Author: User

Console error:R.java was modified manually! Reverting to generated version!

Introduction:

R file loss exception is a common exception in Java development, the cause of this anomaly may be very small, but to the Android developers to create a great deal of trouble, when the program staff to find out where they are wrong, will definitely be careless and wringing, Lament.

Exception prompt:

R.java was modified manually! Reverting to generated version!

or there is no R file generated in the Gen directory in the project and will be error when running the project

my error:

The last time I got this error was because the path to the Android SDK in Eclipse in the new computer was in Chinese, and the Chinese path was in the project workspace, and after I changed the two Chinese paths, the R file was restored again.

Compare Pit is another colleague's wrong reason, after he appeared the R file lost exception, the Android technology leader to look at half a day, did not find where the error, finally dispatched the Director, the director of the adult spent a lot of time, finally found the cause of the error: the project named Android_demo, But the underline _ is Chinese, not English, so there is this problem, colleague's computer is a Mac, and my computer is Windows, I did not find on their own computer how to play Chinese _, so the probability of this problem is still very small.

Other reasons:

Let's talk about other reasons why R files may be missing:

1. The project code is not correct , in the import of other people's project may appear, here to suggest that you best set your own eclipse code to UTF-8 best, most projects will use this code, if you set this code after you import the project is garbled, R file missing Such problems, then you can change to GBK code, if you want to import the project is other encoding, then I can only wish you good luck, spend more time to find out what this code is.

Eclipse Sets the default encoding : Window--preferences--general--workspace, then select Other--utf-8 in the text file encoding below (note that This is an input box, not just a drop-down selection box, which you can enter manually when you can't find the GBK encoding.

Individual Project setup encoding in Eclipse : Right-click Project--properties--resource--text file Encoding, select UTF-8 in other (you can also enter the encoding manually).

2.xml (including layout layouts, values resources, and other XML files) There was an error: either you have an XML format error, or some properties in your XML have been left out of the box, or you may have referred to the wrong XML file.

workaround : XML format error when the General Res folder and its subfolders will appear a small fork, this time will be good to check the corresponding error XML file, but if there is no error, Then you can try to restore the project's XML file to a version that didn't appear before the exception, and then examine your modified XML file one at a.

3.xml files and drawable resource files are not considered uppercase and numeric

Workaround: Change the name of the appropriate file to lowercase or lowercase letters and numbers.

4.Eclipse or ADT plugin version problem, in the adt19 version of the bug has occurred

workaround : Upgrade the latest fixed bug version or uninstall the existing version, using a mature version of the plugin, it is recommended to use the Android development website ADT.

5. The Project SDK version is too low or the version is incorrect

Solution : Right-click on the project--properties--android, select the appropriate SDK version, click Apply--ok.

Here are a few workarounds to help you fix r file loss exceptions:

    • Select the Eclipse menu bar--project, click Build automatically to make it tick, so that eclipse will help you to automatically compile and update the new R file after you have finished modifying the project.
    • Select the project, Project--clean ..., this will erase the old version of the various build files, and generate the latest project generated files, with the new R file;
    • Right-click Projects,Android tools--fix project Properties, fix problems in your project.

Article reference: http://blog.csdn.net/zhufuing/article/details/22228207

Android Learning--r File Loss Exception Reason summary

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.