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.