2011-03-28 3 views
1
private Drawable drawable; 

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

Lorsque j'exécute cela sur mon désir htc ça va, mais sur l'émulateur il se bloque lorsque j'essaie d'initialiser drawable. Pourquoi est-ce?ResourcesNotFoundException lors de l'initialisation Drawable

edit: voici mon 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 
+0

Essayez de rafraîchir votre projet .. ça vaut la peine d'essayer. – Maaalte

+0

pouvez-vous s'il vous plaît poster votre code? –

+0

et l'icône est également dans le dossier «drawable». Pouvez-vous également vous mettre stacktrace? – Tima

Répondre

1

Assurez-vous que vous avez une icône dans tous les dossiers étirables (drawable-LDPI, drawable-mdpi et drawable-hdpi)

+0

oui c'est le cas – Vincent

+0

Il n'est pas nécessaire que l'icône doit être dans tous les trois dossiers..pas vrai ... Il doit être présent dans l'un des dossiers .. –

+0

Je pense, J'ai eu un accident une fois, parce qu'une photo n'était pas dans l'un des dossiers. Mais je ne suis pas sûr – Tima