1. Download our Official Android App: Forums for Android!

Apps R cannot be resolved to a variable

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

  1. aliblu

    aliblu Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    5
    Joined:
    Jul 27, 2011

    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 Newbie
    Rank:
    None
    Points:
    16
    Posts:
    27
    Joined:
    Jul 27, 2011

    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 Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    5
    Joined:
    Jul 27, 2011

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

    alostpacket Over Macho Grande?
    Rank:
    None
    Points:
    513
    Posts:
    7,973
    Joined:
    Nov 29, 2009

    Nov 29, 2009
    7,973
    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 Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    5
    Joined:
    Jul 27, 2011

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

    danBuonocore Lurker
    Rank:
    None
    Points:
    5
    Posts:
    2
    Joined:
    Jan 6, 2012

    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 Lurker
    Rank:
    None
    Points:
    5
    Posts:
    3
    Joined:
    Dec 21, 2012

    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 Lurker
    Rank:
    None
    Points:
    5
    Posts:
    3
    Joined:
    Dec 21, 2012

    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 Android Expert
    Rank:
    None
    Points:
    163
    Posts:
    1,930
    Joined:
    Jul 13, 2010

    Jul 13, 2010
    1,930
    457
    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...