Here are some of the more common solutions.The details are as follows:

1. Sometimes eclipse does not compile automatically,Clean the project and regenerate r.java

2. Select the menu project>clean, as long as bulid automatically is checked, the project will be rebuilt after clicking clean.Because in general,The r.java file will be updated and generated at this time.If the project is wrong,It will not be generated automatically.

3. Select the project,Right-click android tools>fix project properties This operation can sometimes fix some errors.

4.I don't see the match_parent attribute in the SDK layout_height of the old version 1.5/1.6/2.1.android:layout_height="match_parent" This attribute will cause xml not to compile and cannot generate r.java

This is what may happen after downgrading the advanced version.The solution is to replace match_parent with fill_parent

When importing other source code,First make sure that the SDK version of the source code is consistent with your eclipse default version.

5. The project will not automatically compile when there are other xml and class errors.If the jar package is referenced incorrectly, it will not be compiled automatically.


To view the source code version:Open the default.properties file and see what the number is after target=android-7.

Version correspondence:target=android-3<--->android 1.5, target=android-4<--->android 1.6,

target=android-7<--->android 2.1, target=android-8<--->android 2.2, target=android-10<--->android 2.3.3,

target=android-14<--->android 4.0, target=android-15<--->android 4.0.3, target=android-16<--->android 4.1, target=android -17<--->Android 4.2 other self-testing.

The above introduces the solution for writing java programs under eclipse that does not automatically generate r.java files and packages.Hope this article can help everyone.

  • Previous Android background reminder function
  • Next Example analysis of javascript motion framework usage (to achieve zoom-in and zoom-out effects)