2

I recently received crash reports of my app. It says this:

android.content.res.Resources$NotFoundException: File res/drawable-xhdpi/bg.png from drawable resource ID #0x7f020005

and then this:

Caused by: java.lang.IllegalArgumentException: width and height must be > 0
at android.graphics.Bitmap.nativeCreate(Native Method)
at android.graphics.Bitmap.createBitmap(Bitmap.java:477)
at android.graphics.Bitmap.createBitmap(Bitmap.java:444)
at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:349)
at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:601)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:576)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:439)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
at android.content.res.Resources.loadDrawable(Resources.java:1709)

I tested my app on several devices and none of them had crashed. According to the users of my app, this error appears to be on a Samsung Galaxy y pro I really don't know what to do...

vital
  • 1,308
  • 3
  • 13
  • 28
  • Which of your folders have a bg.png? – Raghav Sood Sep 08 '12 at 18:08
  • Only drawable-xhdpi, should I put it into all drawable folders? – vital Sep 08 '12 at 18:47
  • I've seen a similar crash report on an app. The device in question was also a Samsung Galaxy Y. I have not been able to reproduce the issue. – Shellum Oct 01 '12 at 15:34
  • I got the same problem. The reason is propably a rounding issue. My image is only 1 pixel high so the device propably scales it below 0.5px in height and ends up creating a bitmap with a height of 0px. – marsbear May 16 '13 at 13:20
  • Possible duplicate of [Android resource not found exception?](http://stackoverflow.com/questions/7727808/android-resource-not-found-exception) – rds May 09 '16 at 12:32

1 Answers1

1

I found out what was wrong. The Galaxy Y has little screen and so low resolution. And I think this device doesn't know what is xhdpi folder, so you should place your drawable into all folders...

Hope, it helps :)

vital
  • 1,308
  • 3
  • 13
  • 28
  • At least you man place drawable for all other resources in drawable folder or drawable-nodpi. System should look into these folders when it can't find resource in needed. – Roger Alien Nov 17 '12 at 23:05