Android R. Java cannot be generated

Source: Internet
Author: User

Recently, an android project was developed. To call a previous project in a new project and change the previous project to a library project, the new project references the old project. The development tool is eclipse Helios.

After creating a new project, we found that R. java cannot be automatically generated, R. the reason why java files cannot be automatically generated is discussed in stackoverflow. A common reason is that layout XML uses new elements introduced by Android 2.2, such as match_parent, the project compilation target version is set to 2.1. my new project happens to have the compilation target of 2.1. After I change the compilation target to 2.2, the symptoms disappear, but the layout XML content in my new project is very simple. I confirm that no new element of 2.2 is used. There is no valid clue when you carefully check the error message of Eclipse.

It took a long time to find out the real cause of the error. After an occasional operation in eclipse, you can't remember what the operation is. It seems that you want to cancel the automatic compilation, clean the old project, clean the new project, and then build the old project, build a new project -- all of a sudden, eclipse prompts that the old project has a compilation error and is a layout XML file error. Take a closer look and know where the problem is.

Originally, my old project set the compilation target to 2.2, and the layout XML file contains match_parent, while the new project is set to the compilation target 2.1, the setting of a new project is transmitted to the old project along with the Project inclusion, causing eclipse to automatically generate R. the Java mechanism is abnormal.

The pitfalls are that eclipse has never been able to accurately report the cause of the error. After finding the cause for such a long time, you must write it down. I hope this article will be helpful.

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.