R.Java not generated

Waseem picture Waseem · Nov 29, 2011 · Viewed 30.9k times · Source

I have downloaded code from google codes but when I import that project in my eclipse IDE it does not generate R.Java file.I searched many blogs and forums and tried many things like cleaning ,rebuilding, creating project from existing source etc but still facing the problem.Some people mentioned that it is sometimes caused by the SVN client software,but none of them mentioned any solution for that.I will be very thankful to you guys if you download it yourself and find what is the exact problem.

Answer

yorkw picture yorkw · Nov 29, 2011

In general, to make it work:

  1. import project into eclipse (File -> Import -> General -> Existing Projects into Workspace)
  2. in Eclipse, Manually create gen folder and add it as source folder (right click on your project, Build Path -> Configure Build Path -> Add folder)
  3. Clean your project, you suppose to get R.java generated

But It doesn't, Why?

Because there are some compile error (or bug?) regarding to the xml file in res, so R is not genetared (I've tested on my Mac):
In res/values/styles.xml: commented out the following:

<style name="iWindowTitleBackground" parent="android:WindowTitleBackground">    
  <item name="android:background">@drawable/title_bar</item>        
</style>

In res/values/themes.xml: comment out the following:

<item name="android:windowTitleBackgroundStyle">@style/iWindowTitleBackground</item>

Then do a Project -> Clean, you should get R.java generated.

There is bug reported that parent="android:WindowTitleBackground" cannot be resolved in some operating system, check out here for more details.