Stéphane Piette Stéphane Piette - 1 year ago 100
Android Question

R.raw.anything cannot be resolved

I'm developing an android apps with Eclipse.

In my app, I try to read a file : data.xml. I put it in res/raw/, and to access it i'm supposed to use getRessources().openRawResource(;

But Eclipse show me an error : "data" cannot be resolved or is not a field.

But the field is in the gen/ !!!

public final class R {
public static final class raw {
public static final int data=0x7f040000;

Any ideas ?

Solution :
Import the right files !
import my_package.R;

Stop trusting ctrl+shift+O ...

Answer Source

I already faced this problem several weeks ago. You simply have to use com.example.R (where com.example is the name of your package), because Eclipse thinks that you are using android.R by default. Try this out.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download