1

I am currently writing a program for an android app and I keep running into a problem where I get an error "id cannot be resolved or is not a field". For example I have a line of code:

mBodyText = (EditText) findViewById(R.id.body); 

After viewing the R.java class there is no id class. I previously copied and pasted an example online and it also implemented a line of code that was similar and it added the id class to R.java.

I'm just wondering how to correct this problem. I have researched it and some people suggested to others to import android.R and this corrects some errors but then creates new ones saying that the part after is not in that category.

OMG Ponies
  • 325,700
  • 82
  • 523
  • 502
Ryan
  • 11
  • 1
  • 2

3 Answers3

4

Sometimes cleaning the project resolves problems like this. (Select clean from the project menu.)

Programmer Bruce
  • 64,977
  • 7
  • 99
  • 97
3

Clean clean clean. Also saving and restarting helps.

UPGRAYEDD
  • 415
  • 1
  • 8
  • 33
0

If you are using the Eclipse development environment, try just deleting the R.java file and re running the project. I ran into a couple of issues where Eclipse wouldn't update the file right away and I had to delete it to get Eclipse to regenerate it (with the updated values).

Casey
  • 12,070
  • 18
  • 71
  • 107
  • How do I get it to regenerate it? I tried running it, and changing the settings to build automatically and it won't regenerate it. – Ryan May 17 '11 at 01:34
  • are there any errors in your project? Try selecting the project and press F5 or right clicking on the project and selecting Refresh. – Casey May 17 '11 at 01:46