I have an application divided in subpackages, just for personal organization:
com.myname.myapp
|
`- com.myname.myapp.activities
|
`- com.myname.myapp.whatever
|
`- ...
The problem is that the generated R.java is located at com.myname.myapp
and thus when I type R.id.something
in a class from the subpackage com.myname.myapp.activities
, I get R cannot be resolved to a variable
(obvious I guess).
When I click on Organize imports (Ctrl+Shift+O), Eclipse fixes it adding import com.myname.myapp.R
at the top, and everything seems to work perfectly. But on the other hand, Android documentation states this:
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
Knowing that everything is working perfectly, what should I do?
You can import R.file where ever you want.
import com.myname.myapp.R;
or else use at the variable like this
com.myname.myapp.R.id.test
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With