Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R.Java not generated

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.

like image 959
Waseem Avatar asked Nov 29 '11 21:11

Waseem


3 Answers

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.

like image 114
yorkw Avatar answered Oct 24 '22 12:10

yorkw


Whenever your generated R class isn't generated, it indicates that there's a problem with generating it due to some parsing issue from the XML resources. Check the error console in your IDE to figure out what's specifically wrong.

Common problems are:

  • An unescaped character in your strings.xml, for instance you're instead of you\'re
  • Missing layout_width or layout_height tags in layout resources
  • Missing namespace declarations
  • Variable names that aren't supported by Java, for instance due to capitalization or use of spaces, hyphens or other unsupported characters
  • Any other kind of syntax error in XML
  • Check Console for the Issues (Image is attached where console is defining the issue why R is not generating in your project)

enter image description here

like image 3
Naveed Ahmad Avatar answered Oct 24 '22 13:10

Naveed Ahmad


When i come across this problem I delete the gen folder and it will be recreated with all the r files

like image 1
tyczj Avatar answered Oct 24 '22 13:10

tyczj