Resources$NotFoundException drawable-xhdpi from drawable resource



5 down vote favorite
1

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

active oldest votes
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

5 down vote favorite
1

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

active oldest votes
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

你可能感兴趣的:(Resources$NotFoundException drawable-xhdpi from drawable resource)