Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R.raw.anything cannot be resolved [duplicate]

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(R.raw.data);

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

But the field is in the gen/R.java !!!

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

Any ideas ? Thanks


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

Stop trusting ctrl+shift+O ...

like image 742
Stéphane Piette Avatar asked May 04 '11 13:05

Stéphane Piette


3 Answers

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 your IDE thinks that you are using android.R by default. Try this out.

like image 199
Adam Arold Avatar answered Oct 16 '22 20:10

Adam Arold


Try to clean and rebuild your project!

like image 33
necixy Avatar answered Oct 16 '22 21:10

necixy


Or just delete import android.R;.

like image 5
c0dehunter Avatar answered Oct 16 '22 20:10

c0dehunter