Search code examples
androidbitmapfactory

BitmapFactory.decodeResource() does not get my image from drawable


I want to get image in my bitmap like this :

bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.bug);

but this show me error on R.drawable.bug that bug can not be resolve or is not a field please tell where I'm doing things wrong.


Solution

  • Do you have a bug graphic file present in the drawable folder? Have you tried to clean your project in order for R.drawable to be correctly generated?