title: import android.R in Eclipse : Why?
body: <p>An excerpt from the <a href="http://source.android.com/source/using-eclipse.html">documentation</a> : </p>
  
  <blockquote>
    <p>Eclipse sometimes likes to add an import android.R statement at the
    top of your files that use resources, especially when you ask eclipse
    to sort or otherwise manage imports. This will cause your make to
    break. Look out for these erroneous import statements and delete them.</p>
  </blockquote>
  
  <p>My question : <strong>WHY?</strong> Why does eclipse keep on doing this?</p>
  
  <p>I have been developing Android applications using Eclipse for a quite some time now but I have never been able to understand why eclipse does such a thing.</p>
  
  <p>When I use <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>O</kbd> to organize my import statements, <strong><code>import android.R</code></strong> gets added automatically. And all of a sudden my correct code is suddenly covered in red errors, saying that <strong>R cannot be resolved</strong>. It can get really scary for a beginner as he has no idea what he did wrong.</p>
  
  <p>In another scenario, suppose there is something wrong with my layout files and <code>R.java</code> is not being generated, it says that <strong>R cannot be resolved</strong>, as R.java has not been generated due to the errors. As I move my cursor to any of the errors, it suggests me to <code>import android.R</code>.</p>
  
  <p>After working on Android for quite sometime now, I know that <strong>never</strong> to import android.R, but what I have never been able to understand why eclipse keeps on suggesting it, as frankly speaking, adding import android.R never solved any problem of mine. It just added to the existing problems, which used to be really painful during initial days of development.</p>
  
  <p>So, does anyone know the reason behind eclipse making the suggestion to make an incorrect import? Is it just a bug? I don't think it's a bug, as it would have got fixed at least after it was mentioned on the Android documentation.</p>
  
  <p>If it's not a bug, then what is a real purpose of <strong><code>android.R</code></strong>? What does it exactly refer to?</p>
  
  <p>Your opinions/experiences will be really helpful!</p>
  
  <p>Thanks!</p>