NullpointerException of spinner.java:828 firing

I am new to java / android and trying to help with an open source project. I decided it was best to learn how to fix errors, and so I run Monkey in the app to start generating crash reports using bugsense (I don't have access to play.google crash reports). I sequentially encounter a crash below, and since it does not determine where problems arise in the application code, I don’t even know what the problem is. I am not asking for line-by-line corrections (although this is open source), but some useful tips would be greatly appreciated.

Complete Repo: https://github.com/rackspace/android-rackspacecloud Stacktrace + source: http://pastebin.com/YkX7NvdD

Stacktrace: // CRASH: com.rackspace.cloud.android (pid 3330) // Short Msg: java.lang.NullPointerException // Long Msg: java.lang.NullPointerException // Build Label: google/takju/maguro:4.1.1/JRO03C/398337:user/release-keys // Build Changelist: 398337 // Build Time: 1341437384000 // java.lang.NullPointerException // at android.widget.Spinner$DialogPopup.dismiss(Spinner.java:828) // at android.widget.Spinner$DialogPopup.onClick(Spinner.java:862) // at com.android.internal.app.AlertController$AlertParams$3.onItemClick(AlertController.java:924) // at android.widget.AdapterView.performItemClick(AdapterView.java:298) // at android.widget.AbsListView.performItemClick(AbsListView.java:1086) // at android.widget.AbsListView.onKeyUp(AbsListView.java:2996) // at android.widget.ListView.commonKey(ListView.java:2196) // at android.widget.ListView.onKeyUp(ListView.java:2051) // at android.view.KeyEvent.dispatch(KeyEvent.java:2633) // at android.view.View.dispatchKeyEvent(View.java:7086) // at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1354) // at android.widget.ListView.dispatchKeyEvent(ListView.java:2026) // at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1358) // at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1358) // at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1358) // at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1358) // at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1358) // at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:1892) // at com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1369) // at android.app.Dialog.dispatchKeyEvent(Dialog.java:702) // at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1819) // at android.view.ViewRootImpl.deliverKeyEventPostIme(ViewRootImpl.java:3575) // at android.view.ViewRootImpl.deliverKeyEvent(ViewRootImpl.java:3531) // at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:3113) // at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:4153) // at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:4132) // at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:4224) // at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:171) // at android.os.MessageQueue.nativePollOnce(Native Method) // at android.os.MessageQueue.next(MessageQueue.java:125) // at android.os.Looper.loop(Looper.java:124) // at android.app.ActivityThread.main(ActivityThread.java:4745) // at java.lang.reflect.Method.invokeNative(Native Method) // at java.lang.reflect.Method.invoke(Method.java:511) // at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) // at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) // at dalvik.system.NativeStart.main(Native Method) // ** Monkey aborted due to error. Events injected: 5252 :Sending rotation degree=0, persist=false :Dropped: keys=0 pointers=23 trackballs=0 flips=0 rotations=0 ## Network stats: elapsed time=47382ms (0ms mobile, 47382ms wifi, 0ms not connected) ** System appears to have crashed at event 5252 of 10000 using seed 0 
0
source share
1 answer

According to the code that I see in GrepCode , we have the following:

  public void dismiss() { mPopup.dismiss(); mPopup = null; } 

Thus, your NPE is called by mPopup , which is a closed AlertDialog from DialogPopup (a private Spinner class), possibly a dialog box showing the counter settings when you click on it. mPopup installs only on something other than zero in DialogPopup.show() . This method is called when Spinner.performClick() , that is, when clicked with a counter.

But then this is the weird part. The stack trace appears to be when the mPopup element is mPopup because DialogPopup set as OnClickListener . Therefore, at that moment mPopup should not be zero. But when DialogPopup.dismiss() it is zero.

What can this explain? Here is my hypothesis. Well, a monkey is usually pretty fast. Faster than actual users. He may be able to click two elements before mPopup was really fired first by DialogPopup.onClick() . So, we have two calls to DialogPopup.dismiss() , and the second to NPE.

So here are my findings:

  • Since we are dealing only with inner classes, and your code is not responsible for running the code that crashed, this is most likely an Android platform error.
  • To fix this, you must be able to reproduce and debug the eclipse in order to fully understand what is happening. You will need to download the platform code of the Android platform in order to be able to enter the spinner code. Alternatively, you can put the magazine into Spinner code and create Jelly Beans and burn your phone (or replace framework.jar).
  • If my hypothesis is correct, then debugging with ecplise will not help. You need logs to debug the problem. But if my hypothesis is correct, then we think that we should not worry. The average user is unlikely to be able to click so quickly.
  • You could advise the Android guys to do an if-null check. But only after you have found the real root cause. Otherwise, you will mask the problem.
+1
source

All Articles