R cannot be resolved to a variable

Discussion in 'Application Development' started by aliblu, Jul 28, 2011.

  1. aliblu

    aliblu Member
    5

    Jul 27, 2011
    5
    0
    5
    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?
     

    Advertisement
  2. dimiter

    dimiter Active Member
    16

    Jul 27, 2011
    27
    3
    16
    Moscow
    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
    5

    Jul 27, 2011
    5
    0
    5
    Thank you brah
     
  4. alostpacket

    alostpacket Over Macho Grande?
    VIP Member
    513

    Nov 29, 2009
    7,978
    3,603
    513
    Android App Developer
    NY
    yep

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

    aliblu Member
    5

    Jul 27, 2011
    5
    0
    5
    Hmmm so Project > Clean does not seem to be holding up... Any other suggestions?
     
  6. danBuonocore

    danBuonocore New Member
    5

    Jan 6, 2012
    2
    0
    5
    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
    5

    Dec 21, 2012
    3
    0
    5
    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
    5

    Dec 21, 2012
    3
    0
    5
    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
    163

    Jul 13, 2010
    1,934
    458
    163
    Male
    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

Loading...