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

Apps Help! Eclipse can't resolve R.drawable?!?

Discussion in 'Android Development' started by l0ki, Nov 23, 2010.

  1. l0ki

    l0ki Lurker
    Thread Starter
    Rank:
    None
    Points:
    6
    Posts:
    5
    Joined:
    Oct 24, 2010

    Oct 24, 2010
    5
    1
    6
    Let me explain, my laptop crashed and my game was working lovely, but since my laptop has rebooted I keep getting this:

    R cannot be resolved to a variable

    And now I can't even build the program. All the assets are still there and referenced correctly, but eclipse is having a fit...

    Also, importing android.R - does nothing, which is what I thought, and you shouldn't need to import it anyway!?

    Any help is greatly appreciated.
     

    Advertisement

  2. AlbertPucciani

    Rank:
    None
    Points:
    36
    Posts:
    71
    Joined:
    Oct 2, 2010

    Oct 2, 2010
    71
    8
    36
    Computer Programmer
    Hi,

    Check that the project is an Android project first. Right-click the project, go to Android Tools (At the bottom), then it's something like "Convert To Android Project", if you don't see that, then it is already an Android Project. Assuming that the SDK is setup on your computer, right click the Project, go to Properties.

    Do you see an "Android" option? If so, check the version of Android you are targeting.

    Then go to "Java Build Path", press "Add External Jars", then and search for the Android jar that targets your runtime. In my case, I target 2.2 and I found the JAR at "C:\Program Files\eclipse\android-sdk-windows\platforms\android-8\android.jar", your file is probably different.

    You'll need to press "Ctrl-B" if you're using Windows to initiate a Build All in Eclipse.

    Let me know if you have any other questions.
     
  3. mohitjaitly

    mohitjaitly Member
    Rank:
    None
    Points:
    15
    Posts:
    34
    Joined:
    Oct 18, 2010

    Oct 18, 2010
    34
    0
    15
    India
    Well, you should not import android.R.
    Make sure your android project is set up (as mentioned above as well). Clean-Build and import the R class from gen folder. This R class is automatically generated when you build your project.
     

Share This Page

Loading...