Question

I'm creating an application with image sharing elements. Everything works fine except when I try to run my app on emulator, it's unable to show the correct output as per the code. On the other hand, when I test my application on my Android device, it shows an Unexpected Error. I tried to restart my device and also created a new emulator, but none of them were helpful for me.

The offending code, line 55 on FullImageActivity is

Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.id.full_image_view);

Here is the LogCat

04-23 05:03:07.907: W/EGL_emulation(1172): eglSurfaceAttrib not implemented
04-23 05:03:08.137: D/dalvikvm(1172): GC_FOR_ALLOC freed 33K, 3% free 4846K/4952K, paused 39ms, total 40ms
04-23 05:03:10.607: W/EGL_emulation(1172): eglSurfaceAttrib not implemented
04-23 05:03:11.767: D/AndroidRuntime(1172): Shutting down VM
04-23 05:03:11.777: W/dalvikvm(1172): threadid=1: thread exiting with uncaught exception (group=0xb4a8cb90)
04-23 05:03:11.777: E/AndroidRuntime(1172): FATAL EXCEPTION: main
04-23 05:03:11.777: E/AndroidRuntime(1172): Process: com.lol.meme, PID: 1172
04-23 05:03:11.777: E/AndroidRuntime(1172): java.lang.NullPointerException
04-23 05:03:11.777: E/AndroidRuntime(1172):     at com.lol.meme.FullImageActivity.onOptionsItemSelected(FullImageActivity.java:55)
04-23 05:03:11.777: E/AndroidRuntime(1172):     at android.app.Activity.onMenuItemSelected(Activity.java:2599)
04-23 05:03:11.777: E/AndroidRuntime(1172):     at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:1012)
04-23 05:03:11.777: E/AndroidRuntime(1172):     at com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:735)
04-23 05:03:11.777: E/AndroidRuntime(1172):     at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:152)
04-23 05:03:11.777: E/AndroidRuntime(1172):     at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:874)
04-23 05:03:11.777: E/AndroidRuntime(1172):     at com.android.internal.view.menu.MenuPopupHelper.onItemClick(MenuPopupHelper.java:177)
04-23 05:03:11.777: E/AndroidRuntime(1172):     at android.widget.AdapterView.performItemClick(AdapterView.java:299)
04-23 05:03:11.777: E/AndroidRuntime(1172):     at android.widget.AbsListView.performItemClick(AbsListView.java:1113)
04-23 05:03:11.777: E/AndroidRuntime(1172):     at android.widget.AbsListView$PerformClick.run(AbsListView.java:2904)
04-23 05:03:11.777: E/AndroidRuntime(1172):     at android.widget.AbsListView$3.run(AbsListView.java:3638)
04-23 05:03:11.777: E/AndroidRuntime(1172):     at android.os.Handler.handleCallback(Handler.java:733)
04-23 05:03:11.777: E/AndroidRuntime(1172):     at android.os.Handler.dispatchMessage(Handler.java:95)
04-23 05:03:11.777: E/AndroidRuntime(1172):     at android.os.Looper.loop(Looper.java:137)
04-23 05:03:11.777: E/AndroidRuntime(1172):     at android.app.ActivityThread.main(ActivityThread.java:4998)
04-23 05:03:11.777: E/AndroidRuntime(1172):     at java.lang.reflect.Method.invokeNative(Native Method)
04-23 05:03:11.777: E/AndroidRuntime(1172):     at java.lang.reflect.Method.invoke(Method.java:515)
04-23 05:03:11.777: E/AndroidRuntime(1172):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
04-23 05:03:11.777: E/AndroidRuntime(1172):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
04-23 05:03:11.777: E/AndroidRuntime(1172):     at dalvik.system.NativeStart.main(Native Method)
04-23 05:03:15.517: I/Process(1172): Sending signal. PID: 1172 SIG: 9
04-23 05:03:16.447: D/dalvikvm(1200): GC_FOR_ALLOC freed 60K, 4% free 3117K/3244K, paused 27ms, total 30ms
04-23 05:03:16.707: D/(1200): HostConnection::get() New Host Connection established 0xb8c69818, tid 1200
04-23 05:03:16.967: W/EGL_emulation(1200): eglSurfaceAttrib not implemented
04-23 05:03:16.977: D/OpenGLRenderer(1200): Enabling debug mode 0
04-23 05:03:17.057: D/dalvikvm(1200): GC_FOR_ALLOC freed 5K, 4% free 3206K/3336K, paused 21ms, total 22ms
04-23 05:03:17.127: D/dalvikvm(1200): GC_FOR_ALLOC freed <1K, 4% free 3608K/3740K, paused 20ms, total 21ms
04-23 05:03:17.247: D/dalvikvm(1200): GC_FOR_ALLOC freed <1K, 4% free 4027K/4164K, paused 20ms, total 20ms
04-23 05:03:17.357: D/dalvikvm(1200): GC_FOR_ALLOC freed 1K, 4% free 4345K/4480K, paused 21ms, total 21ms
04-23 05:03:17.447: I/Choreographer(1200): Skipped 63 frames!  The application may be doing too much work on its main thread.
Was it helpful?

Solution

check your second argument type for resources which is an ID. you should provide a valid argument type for this specific resource i.e, use R.Drawable.FILENAME what you are doing is that you providing the Resources an id argument which causing you an Unexpected Error Its Like fueling your petrol car with diesel :x

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top