2012年6月18日

【Android】R.java is missing?

When creating a new Android project, but got an error, can't find 'R'. Tracing the project, we can find that R.java is missing.

This is due to setup incorrect target build settings. Target build was set toAndroid 2.1 (SDK v7) where his layout XML used Android 2.2 (SDK v8) elements (layout parametermatch_parent), due to this there was no way for Eclipse to correctly generate the R.java file which caused all the problems.

Solution:

  • Remove  import android.R.*
  • Project->Clean , to regenerate R.java
Reference:

沒有留言: