1

When I try to make a reference to any file in //res/raw/ Through the R class, it acts as though I do not have the 'raw' directory in the project. I checked in the project files as well as in the eclipse IDE - it is definitely there.
here:

MediaPlayer mp = MediaPlayer.create(Project.this, R.raw.Gunshot);

This code prevents me from compiling... Eclipse says "raw cannot be resolved or is not a field.

I have restarted, refreshed, and built the project without that code, but it will not go away. HELP

brainmurphy1
  • 1,082
  • 1
  • 19
  • 24
  • According to your last comment, every reference to `R` is considered an error. But it's a common problem: [R cannot be resolved](http://stackoverflow.com/a/5780990/1267661) – Sam Jun 01 '12 at 01:20
  • Here's a [better description](http://stackoverflow.com/q/885009/1267661). – Sam Jun 01 '12 at 01:27

4 Answers4

2

Find "import android.R" and delete them. Then Clean your project and Build it.

This would be the most common problem in Eclipse Android.

Check this out, this you can find many solutions here.

Community
  • 1
  • 1
CMA
  • 2,758
  • 5
  • 28
  • 40
2

I figured it out. I was looking the logger and did not see in the console that filenames in the 'raw' folder have to be lowercase. I think it also does not build the 'raw' object until there are files inside it. It thus appeared to never generate the object. Thanks guys.

brainmurphy1
  • 1,082
  • 1
  • 19
  • 24
0

how about Project>clean and rebuild the project?

Kurosawa Hiroyuki
  • 1,217
  • 2
  • 14
  • 22
0

On Android Studio 4.0 after:

  • Clean&Rebuild
  • Rename raw file to lowercase a-z, 0-9 and an underline

Reference resolved only after Invalidate Caches and Restart AS.

dansamosudov
  • 102
  • 1
  • 1
  • 4