资源$ NotFoundException绘制-xhdpi从绘制资源 [英] Resources$NotFoundException drawable-xhdpi from drawable resource

查看:203
本文介绍了资源$ NotFoundException绘制-xhdpi从绘制资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我检查我的错误报告和我们不时从我们的应用程序,这个错误报告。 我不能品脱点什么实际的问题。 这个资源确实存在,大多数设备的正常工作,但像LG-E510或U8815一些特定的设备都无法加载该资源。

任何想法?

  android.content.res.Resources $ NotFoundException:文件RES /绘制-xhdpi /从绘制资源ID#0x7f02007f action_bar_search_icon.png
在android.content.res.Resources.loadDrawable(Resources.java:1714)
在android.content.res.Resources.getDrawable(Resources.java:581)
在com.actionbarsherlock.internal.view.menu.MenuItemImpl.getIcon(MenuItemImpl.java:384)
在com.actionbarsherlock.internal.view.menu.ActionMenuItemView.initialize(ActionMenuItemView.java:128)
在com.actionbarsherlock.internal.view.menu.ActionMenu$p$psenter.bindItemView(ActionMenu$p$psenter.java:192)
在com.actionbarsherlock.internal.view.menu.BaseMenu presenter.getItemView(BaseMenu presenter.java:176)
在com.actionbarsherlock.internal.view.menu.ActionMenu$p$psenter.getItemView(ActionMenu$p$psenter.java:178)
 

解决方案

正如您所指出的,如果手机/标签访问xhdpi目录,然后我们期望它相应地放大图像,以适应屏幕。因此,我们预计,如果在目录中的任何一个资源的存在,那么我们将永远不会看到一个ResourceNotFound例外。但是:

xhdpi只在Android SDK中8中引入的,所以如果你的目标SDK 7及更早版本,你可能会遇到问题:

仅使用XHDPI可绘制在Android应用?

的另一个原因机器人可能不能够访问xhdpi目录是如果设备在屏幕兼容的模式运行:

<一个href="http://stackoverflow.com/questions/9434884/android-extra-large-images-placed-in-res-drawable-xhdpi-arent-showing-on-tabl">Android - ?放在RES /绘制-xhdpi超大图像不显示在平板电脑模拟器,为什么

另一个可能的原因是,如果你的可拉伸很小,其尺寸中的一个被作为缩放的结果舍入为零:

<一个href="http://stackoverflow.com/questions/15428441/android-resource-not-found-because-of-width-and-height">Android资源未找到,因为宽度和高度的

最后,有可能是某些OEM版本的Andr​​oid可能会在一个非标准的方式实施这一(如增强性能通过不搜索xhdpi目录,如果他们的设备是华电国际):

<一个href="http://stackoverflow.com/questions/15621876/android-drawable-hdpi-xhdpi-mdpi-ldpi-concept">Android可绘制华电国际xhdpi MDPI LDPI概念

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)

解决方案

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

这篇关于资源$ NotFoundException绘制-xhdpi从绘制资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆