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

2
  • According to your last comment, every reference to R is considered an error. But it's a common problem: R cannot be resolved Commented Jun 1, 2012 at 1:20
  • Here's a better description. Commented Jun 1, 2012 at 1:27

4 Answers 4

4

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.

Sign up to request clarification or add additional context in comments.

Comments

3

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.

Comments

0

how about Project>clean and rebuild the project?

3 Comments

Well something happened at least. I cleaned, and then it gave me the same error, except now it couldn't find "R"!
I then imported it, and now it is giving me trouble with the actual resources, but now it is doing it everywhere, not just in the "raw" file.
is there any error generating R at console? If res folder has error, it fails to generate R class
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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.