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?

  • Difference between AlarmManager and ScheduledExecutorService
  • Using Android phone as USB Host to mount external drives to phone and accessing the memory of the external drive through phone
  • How do I discover a Chromecast device using Android?
  • Android how to fix camera orientation
  • Is there a way to use GCM in Android without a dedicated server?
  • Android Studio minSdkVersion and targetSdkVersion warning
  • Related posts:

    PopupMenu with icons
    Opening source code from debug view edits .class after Android R18 update
    put tabs in the bottom of screen
    How can i do factory reset using adb in android?
    Android: Google Analytics availability in Google Play Services?
    Maximum cache size
  • Android Api 23 Change Navigation View headerLayout textview
  • Camera Force Closing issue in Samsung Galaxy S3 version 4.1.1
  • Spring RestTemplate HTTP Post with parameters cause 400 bad request error
  • How to create Live Wallpaper in Android?
  • Retrofit 2 - Dynamic URL
  • Check the bandwidth rate in Android
  • 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.