R cannot be resolved to a variable

Last Updated:

  1. aliblu

    aliblu Member

    My DroidAvtivity.Java file started with this error..."R cannot be resolved to a variable"...if you could please tell me what happened to my file?

  2. dimiter

    dimiter Active Member

    Try Project->Clean. Also sure, what variable is declarated (ex. , if it's view id, check existence this id in xml)

    If project get start, and error go down the drain, it's eclipse feature.
    alostpacket likes this.
  3. aliblu

    aliblu Member

    Thank you brah
  4. alostpacket

    alostpacket Over Macho Grande? VIP Member


    Project > clean is like the ultimate first line of defense in all things weird with eclipse. :)
  5. aliblu

    aliblu Member

    Hmmm so Project > Clean does not seem to be holding up... Any other suggestions?
  6. danBuonocore

    danBuonocore New Member

    I have tried Project > Clean numerous times and it still has not resolved the issue. Other sites have said to reinstall the .android folder, remove the import R line, change the target of the run/debug for the project, turn automatic rebuild off, delete and recreate all AVDs, etc. but nothing has worked. Any ideas?
  7. israfelwater

    israfelwater New Member

    I hate this error, I have also had success with right click on project > android tools > fix project properties, but that is not work for me now. ahhhhh. I can't rebuild because my project has errors everywhere where I use R...
  8. israfelwater

    israfelwater New Member

    oh, nevermind, All I had to do was delete the line in the xml file which was throwing an error, save, and turn on automatic builds. Then the error went away and "/res" built properly under the "gen" dir.

    Odd, I commented out the line but the error wouldn't go away. I had to delete it...

    here is a helpful link for this error

    eclipse - R cannot be resolved - Android error - Stack Overflow
  9. jonbonazza

    jonbonazza Well-Known Member

    If there are errors in ANY of your resources, whether it be xml syntax, illegal file names, etc.., the R.java file will not be generated.

Share This Page