Resources$NotFoundException drawable-xhdpi from drawable resource



I was checking my bug reports and from time to time we get this bug report from our app. I can't pint point what is the actual problem. This resource does exist, most of devices work fine but some specific devices like LG-E510 or U8815 just cant load this resource.

Any ideas?

android.content.res.Resources$NotFoundException: File res/drawable-xhdpi/action_bar_search_icon.png from drawable resource ID #0x7f02007f
at android.content.res.Resources.loadDrawable(Resources.java:1714)
at android.content.res.Resources.getDrawable(Resources.java:581)
at com.actionbarsherlock.internal.view.menu.MenuItemImpl.getIcon(MenuItemImpl.java:384)
at com.actionbarsherlock.internal.view.menu.ActionMenuItemView.initialize(ActionMenuItemView.java:128)
at com.actionbarsherlock.internal.view.menu.ActionMenuPresenter.bindItemView(ActionMenuPresenter.java:192)
at com.actionbarsherlock.internal.view.menu.BaseMenuPresenter.getItemView(BaseMenuPresenter.java:176)
at com.actionbarsherlock.internal.view.menu.ActionMenuPresenter.getItemView(ActionMenuPresenter.java:178)
share | improve this question
 
 
is this resource exist in drawable-xhdpi folder, because we have to put the resources according to their resolution, means low devices will use resources from ldpi folder and medium will from mdpi and so on...so first of all check that whether this resource is exist in appropriate folder. –   Ajit  Apr 19 '13 at 9:00
 
Or else put your resource into the default drawable folder so that the system will pick that if nothing is appropriate –   vinoth  Apr 19 '13 at 9:07
 
Well devices are able to downscale resources from XHDPI to any dencity they need. So that is not the issue.–   Martynas Jurkus  Apr 19 '13 at 9:17 
 
apparently it is searching for the resource explicitely in the xhdpi folder. is it there ? and if not, is it in drawable or in drawable-hdpi ? –   njzk2  Apr 19 '13 at 9:18
 
the resource is in xhdpi and only in xhdpi. –   Martynas Jurkus  Apr 19 '13 at 9:21
add comment

2 Answers

up vote 3 down vote accepted
+50

As you have stated, if the phone / tab accesses the xhdpi directory then we expect it to scale the image appropriately to fit the screen. Therefore we expect that if the resource exists in ANY ONE of the directories then we will never see a ResourceNotFound exception. HOWEVER:

xhdpi was only introduced in Android SDK 8, so if you target SDK 7 and earlier you may run into problems:

Only use XHDPI drawables in Android app?

Another reason why Android may not be able to access the xhdpi directory is if the device is running in screen compatability mode:

Android - Extra large images placed in res/drawable-xhdpi aren't showing on tablet emulator, why?

Another possible reason is if your drawable is very small and one of its dimensions is rounded to zero as a result of scaling:

Android resource not found because of width and height

Finally, it is possible that some OEM versions of Android may implement this in a non-standard way (e.g "enhancing performance" by not searching the xhdpi directory if their device is hdpi):

Android Drawable hdpi xhdpi mdpi ldpi concept

I was checking my bug reports and from time to time we get this bug report from our app. I can't pint point what is the actual problem. This resource does exist, most of devices work fine but some specific devices like LG-E510 or U8815 just cant load this resource.

Any ideas?

android.content.res.Resources$NotFoundException: File res/drawable-xhdpi/action_bar_search_icon.png from drawable resource ID #0x7f02007f
at android.content.res.Resources.loadDrawable(Resources.java:1714)
at android.content.res.Resources.getDrawable(Resources.java:581)
at com.actionbarsherlock.internal.view.menu.MenuItemImpl.getIcon(MenuItemImpl.java:384)
at com.actionbarsherlock.internal.view.menu.ActionMenuItemView.initialize(ActionMenuItemView.java:128)
at com.actionbarsherlock.internal.view.menu.ActionMenuPresenter.bindItemView(ActionMenuPresenter.java:192)
at com.actionbarsherlock.internal.view.menu.BaseMenuPresenter.getItemView(BaseMenuPresenter.java:176)
at com.actionbarsherlock.internal.view.menu.ActionMenuPresenter.getItemView(ActionMenuPresenter.java:178)
share | improve this question
 
    
is this resource exist in drawable-xhdpi folder, because we have to put the resources according to their resolution, means low devices will use resources from ldpi folder and medium will from mdpi and so on...so first of all check that whether this resource is exist in appropriate folder. –   Ajit  Apr 19 '13 at 9:00
    
Or else put your resource into the default drawable folder so that the system will pick that if nothing is appropriate –   vinoth  Apr 19 '13 at 9:07
    
Well devices are able to downscale resources from XHDPI to any dencity they need. So that is not the issue.–   Martynas Jurkus  Apr 19 '13 at 9:17 
    
apparently it is searching for the resource explicitely in the xhdpi folder. is it there ? and if not, is it in drawable or in drawable-hdpi ? –   njzk2  Apr 19 '13 at 9:18
    
the resource is in xhdpi and only in xhdpi. –   Martynas Jurkus  Apr 19 '13 at 9:21
add comment

2 Answers

up vote 3 down vote accepted
+50

As you have stated, if the phone / tab accesses the xhdpi directory then we expect it to scale the image appropriately to fit the screen. Therefore we expect that if the resource exists in ANY ONE of the directories then we will never see a ResourceNotFound exception. HOWEVER:

xhdpi was only introduced in Android SDK 8, so if you target SDK 7 and earlier you may run into problems:

Only use XHDPI drawables in Android app?

Another reason why Android may not be able to access the xhdpi directory is if the device is running in screen compatability mode:

Android - Extra large images placed in res/drawable-xhdpi aren't showing on tablet emulator, why?

Another possible reason is if your drawable is very small and one of its dimensions is rounded to zero as a result of scaling:

Android resource not found because of width and height

Finally, it is possible that some OEM versions of Android may implement this in a non-standard way (e.g "enhancing performance" by not searching the xhdpi directory if their device is hdpi):

Android Drawable hdpi xhdpi mdpi ldpi concept

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值