开发者

ResourcesNotFoundException when initialising Drawable

开发者 https://www.devze.com 2023-02-20 01:47 出处:网络
private Drawable drawable; drawable = this.getResources().getDrawable(R.drawable.icon); When I run this on my htc desire it goes, but on emulator it crashes when I try to initialiser drawable. Why
private Drawable drawable;

drawable = this.getResources().getDrawable(R.drawable.icon);

When I run this on my htc desire it goes, but on emulator it crashes when I try to initialiser drawable. Why is this?

edit: here is my stacktrace

  03-28 13:27:58.453: ERROR/ActivityThread(888): Failed to find provider info for com.google.settings
03-28 13:28:06.414: ERROR/AndroidRuntime(888): Uncaught handler: thread main exiting due to uncaught exception
03-28 13:28:06.486: ERROR/AndroidRuntime(888): java.lang.RuntimeException: Unable to start activity ComponentInfo{be.test.helloworld/be.test.helloworld.MyMapActivityII}: android.content.res.Resources$NotFoundException: Resource ID #0x7f020000
03-28 13:28:06.486: ERROR/AndroidRuntime(888):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2268)
03-28 13:28:06.486: ERROR/AndroidRuntime(888):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2284)
03-28 13:28:06.486: ERROR/AndroidRuntime(888):     at android.app.ActivityThread.access$1800(ActivityThread.java:112)
03-28 13:28:06.486: ERROR/AndroidRuntime(888):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1692)
03-28 13:28:06.486: ERROR/AndroidRuntime(888):     at android.os.Handler.dispatchMessage(Handler.java:99)
03-28 13:28:06.486: ERROR/AndroidRuntime(888):     at android.os.Looper.loop(Looper.java:123)
03-28 13:28:06.486: ERROR/AndroidRuntime(888):     at android.app.ActivityThread.main(ActivityThread.java:3948)
03-28 13:28:06.486: ERROR/AndroidRuntime(888):     at java.lang.reflect.Method.invokeNative(Native Method)
03-28 13:28:06.486: ERROR/AndroidRuntime(888):     at java.lang.reflect.Method.invoke(Method.java:521)
03-28 13:28:06.486: ERROR/AndroidRuntime(888):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
03-28 13:28:06.486: ERROR/AndroidRuntime(888):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
03-28 13:28:06.486: ERROR/AndroidRuntime(888):     at dalvik.system.NativeStart.main(Native Method)
03-28 13:28:06.486: ERROR/AndroidRuntime(888): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f020000
03-28 13:28:06.486: ERROR/AndroidRuntime(888):     at android.content.res.Resources.getValue(Resources.java:846)
03-28 13:28:06.486: ERROR/AndroidRuntime(888):     at android.content.res.Resources.getDrawable(Resources.java:534)
03-28 13:28:06.486: ERROR/AndroidRuntime(888):     at be.开发者_开发问答test.helloworld.MyMapActivityII.initOverlays(MyMapActivityII.java:44)
03-28 13:28:06.486: ERROR/AndroidRuntime(888):     at be.test.helloworld.MyMapActivityII.onCreate(MyMapActivityII.java:38)
03-28 13:28:06.486: ERROR/AndroidRuntime(888):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
03-28 13:28:06.486: ERROR/AndroidRuntime(888):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2231)
03-28 13:28:06.486: ERROR/AndroidRuntime(888):     ... 11 more


Make sure you have an icon in all of the drawable folders (drawable-ldpi, drawable-mdpi and drawable-hdpi)

0

精彩评论

暂无评论...
验证码 换一张
取 消