title: Accessing R.java from different packages
body: <p>I have an application divided in subpackages, just for personal organization:</p>
  
  <pre><code>com.myname.myapp
   |
   `-  com.myname.myapp.activities
   |
   `-  com.myname.myapp.whatever
   |
   `-  ...
  </code></pre>
  
  <p>The problem is that the generated R.java is located at <code>com.myname.myapp</code> and thus when I type <code>R.id.something</code> in a class from the subpackage <code>com.myname.myapp.activities</code>, I get <code>R cannot be resolved to a variable</code> (obvious I guess).</p>
  
  <p>When I click on <em>Organize imports</em> (Ctrl+Shift+O), Eclipse fixes it adding <code>import com.myname.myapp.R</code> at the top, and everything seems to work perfectly. But on the other hand, <a href="http://source.android.com/source/using-eclipse.html" rel="nofollow noreferrer">Android documentation</a> states this:</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>Knowing that everything is working perfectly, what should I do?</p>