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


Last Updated: 2010-11-25 06:02:05
  1. l0ki

    l0ki Member

    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

    AlbertPucciani Well-Known Member

    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 Active Member

    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