Android: R.drawable not showing my image?

In my android 2.2 app, I’ve added my image to the res/drawable-mdpi folder. However, I cannot seem to access it using R.drawable.. As far as I know, there isn’t any additional configuration I need to do – any help?

  • layout_weight attribute in <include> tag
  • ADB - Android - Getting the name of the current activity
  • How can I change the background color of a spinner popup?
  • Android Studio vs Eclipse IDE
  • Gradle errors in Android Studio
  • Duplicate permission request after orientation change
  • Related posts:

    Android export give a &ldquo;Conversion to Dalvik format failed error1&rdquo;
    How can i Load a jar file dynamically in an android application (4.0.3)
    Android Apply Palette
    Eclipse: Android Device Chooser - Unknown Android 2.3.4 Device
    Disable animation of drawer icon in double navigation drawer for right drawer
    Android webview, start ACTION_VIEW activity when the url could not be handled by webview
  • Google Cloud Messaging - messages either received instantly or with long delay
  • Android - Custom rating bar looks like its bleeding
  • How to create android apps with root access?
  • How do I make WRAP_CONTENT work on a RecyclerView
  • Is there an Erlang implementation for Android?
  • Duplicate files during packaging of APK app-debug-unaligned.apk
  • 5 Solutions collect form web for “Android: R.drawable not showing my image?”

    I figured this out. The issue was that the project was importing android.R instead of using the generated R file – if you encounter this problem, check your imports to make sure the correct package/file is being imported.

    Have Faced the same sort of error, instead of importing contents (pictures) properly, I copied to drawable-hdpi folder, which in turn wasn’t generating R Constant ID, you have to import it, rather than just dropping it there.

    I had the same problem for a different reason. In my case I had illegal characters in the image file name and hadn’t noticed the console message complaining about it.

    Once I’d renamed icon-1.png to icon_1.png all was well.

    You need to use a fully qualified name when importing the generated R file. Check your import statements.

    Take the following package statement:

    package me.rhys.example;

    Then the generated R file can be imported using:

    import me.rhys.example.R;

    If you would like to import a file, for example an image file then you need to go to the res/drawable-XXXX and right click on the folder and then select “import” and in the setup select general files and go to the folder where the images are and select the files that you want to import… Netbeans does this automatically but the eclipse lack this feature

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.