【发布时间】:2012-09-08 17:40:25
【问题描述】:
我最近收到了关于我的应用的崩溃报告。它是这样说的:
android.content.res.Resources$NotFoundException: File res/drawable-xhdpi/bg.png from drawable resource ID #0x7f020005
然后是这个:
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)
我在多台设备上测试了我的应用,但没有一台设备崩溃。 根据我的应用程序用户的说法,这个错误似乎出现在三星 Galaxy y pro 上 我真的不知道该怎么办......
【问题讨论】:
-
您的哪些文件夹有 bg.png?
-
只有drawable-xhdpi,要不要放到所有drawable文件夹里?
-
我在某个应用上看到过类似的崩溃报告。有问题的设备也是三星 Galaxy Y。我无法重现该问题。
-
我遇到了同样的问题。原因可能是一个四舍五入的问题。我的图像只有 1 像素高,因此设备可以适当地将其缩放到 0.5 像素以下,并最终创建一个高度为 0 像素的位图。