NPE on menu creation for certain devices - android

On a live app, I'm receiving the following crash report:
java.lang.NullPointerException
at android.support.v7.app.ActionBarImplICS.getThemedContext(ActionBarImplICS.java:302)
at android.support.v7.app.ActionBarImplJB.getThemedContext(ActionBarImplJB.java:20)
at android.support.v7.app.ActionBarActivityDelegate.getActionBarThemedContext(ActionBarActivityDelegate.java:210)
at android.support.v7.app.ActionBarActivityDelegate.getMenuInflater(ActionBarActivityDelegate.java:100)
at android.support.v7.app.ActionBarActivity.getMenuInflater(ActionBarActivity.java:72)
at android.app.Activity.onCreatePanelMenu(Activity.java:2579)
at android.support.v4.app.FragmentActivity.onCreatePanelMenu(FragmentActivity.java:225)
at android.support.v7.app.ActionBarActivity.superOnCreatePanelMenu(ActionBarActivity.java:233)
at android.support.v7.app.ActionBarActivityDelegateICS.onCreatePanelMenu(ActionBarActivityDelegateICS.java:146)
at android.support.v7.app.ActionBarActivity.onCreatePanelMenu(ActionBarActivity.java:200)
at android.support.v7.app.ActionBarActivityDelegateICS$WindowCallbackWrapper.onCreatePanelMenu(ActionBarActivityDelegateICS.java:293)
at com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:507)
at com.android.internal.policy.impl.PhoneWindow.onKeyDownPanel(PhoneWindow.java:964)
at com.android.internal.policy.impl.PhoneWindow.onKeyDown(PhoneWindow.java:1670)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:2227)
at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:4562)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4538)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4143)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4193)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4162)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4247)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4170)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4304)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4143)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4193)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4162)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4170)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4143)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4193)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4162)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4280)
at android.view.ViewRootImpl$ImeInputStage.onFinishedInputEvent(ViewRootImpl.java:4430)
at android.view.inputmethod.InputMethodManager$PendingEvent.run(InputMethodManager.java:2223)
at android.view.inputmethod.InputMethodManager.invokeFinishedInputEventCallback(InputMethodManager.java:1895)
at android.view.inputmethod.InputMethodManager.finishedInputEvent(InputMethodManager.java:1886)
at android.view.inputmethod.InputMethodManager$ImeInputEventSender.onInputEventFinished(InputMethodManager.java:2200)
at android.view.InputEventSender.dispatchInputEventFinished(InputEventSender.java:141)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:132)
at android.os.Looper.loop(Looper.java:124)
at android.app.ActivityThread.main(ActivityThread.java:5419)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
at dalvik.system.NativeStart.main(Native Method)
It seems to be coming from only some types of devices: Samsung Galaxy S4, Note (II and 3) and Tab3 Lite.
From the stacktrace I'm only able to see that this seems to relate to the menu creation. Anybody could help me understand what's going on here ?

Related

Unable to destroy activity Caused by java.lang.NullPointerException

I have an application with fragments. I have installed fabric (Crashlytics) and I received the same issue that I can't reproduce in emulator. The android that crash is 2.3.4/2.3.5/2.3.6/4.0.4/4.1.1/4.1.2 the rest of versions function correctly.
In my main activity (in destroy function) I have a super.ondestroy();
The error is:
Fatal Exception: java.lang.RuntimeException: Unable to destroy activity {XXXX.BaseActivity_new}: java.lang.NullPointerException
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3316)
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3334)
at android.app.ActivityThread.access$1200(ActivityThread.java:137)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1263)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4838)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:875)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:642)
at dalvik.system.NativeStart.main(NativeStart.java)
Caused by java.lang.NullPointerException
at android.webkit.WebViewClassic.requestFocus(WebViewClassic.java:6938)
at android.webkit.WebView.requestFocus(WebView.java:2074)
at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:2373)
at android.view.ViewGroup.requestFocus(ViewGroup.java:2329)
at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:2373)
at android.view.ViewGroup.requestFocus(ViewGroup.java:2332)
at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:2373)
at android.view.ViewGroup.requestFocus(ViewGroup.java:2329)
at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:2373)
at android.view.ViewGroup.requestFocus(ViewGroup.java:2329)
at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:2373)
at android.view.ViewGroup.requestFocus(ViewGroup.java:2329)
at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:2373)
at android.view.ViewGroup.requestFocus(ViewGroup.java:2329)
at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:2373)
at android.view.ViewGroup.requestFocus(ViewGroup.java:2332)
at android.view.View.requestFocus(View.java:6440)
at android.view.View.requestFocus(View.java:6419)
at android.view.View.ensureInputFocusOnFirstFocusable(View.java:4373)
at android.view.ViewGroup.removeViewInternal(ViewGroup.java:3666)
at android.view.ViewGroup.removeViewInternal(ViewGroup.java:3626)
at android.view.ViewGroup.removeView(ViewGroup.java:3558)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1165)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1252)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1234)
at android.support.v4.app.FragmentManagerImpl.dispatchDestroy(FragmentManager.java:2083)
at android.support.v4.app.FragmentController.dispatchDestroy(FragmentController.java:244)
at android.support.v4.app.FragmentActivity.onDestroy(FragmentActivity.java:368)
at android.support.v7.app.AppCompatActivity.onDestroy(AppCompatActivity.java:203)
at XXXX.BaseActivity_new.onDestroy(BaseActivity_new.java:878)
at android.app.Activity.performDestroy(Activity.java:5174)
at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1109)
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3303)
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3334)
at android.app.ActivityThread.access$1200(ActivityThread.java:137)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1263)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4838)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:875)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:642)
at dalvik.system.NativeStart.main(NativeStart.java)
Help me? How to solve this issue.

Android: Registring to server Nullpointer exception at org.json.JSONTokener.nextCleanInternal

I did this tutorial https://www.youtube.com/watch?v=ArJDXM-HHqk&spfreload=10
and also copied this working code from other student: https://gist.github.com/anonymous/e0bfcd7a9e954ae574d59c123cb0c4ae
And still I get this error again and again:
01-01 23:24:00.727 2759-2759/com.example.loginapp E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.NullPointerException
at org.json.JSONTokener.nextCleanInternal(JSONTokener.java:116)
at org.json.JSONTokener.nextValue(JSONTokener.java:94)
at org.json.JSONObject.<init>(JSONObject.java:154)
at org.json.JSONObject.<init>(JSONObject.java:171)
at com.example.loginapp.BackgroundTask.onPostExecute(BackgroundTask.java:52)
at com.example.loginapp.BackgroundTask.onPostExecute(BackgroundTask.java:26)
at android.os.AsyncTask.finish(AsyncTask.java:631)
at android.os.AsyncTask.access$600(AsyncTask.java:177)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:644)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5413)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
at dalvik.system.NativeStart.main(Native Method)
Silly me, I had a typo in the method name, "Register" instead of "register".
now it works fine.

ArrayIndexOutOfBoundsException in android.view.WindowManagerGlobal

I have received this error in my remote app crash reporter:
java.lang.ArrayIndexOutOfBoundsException: length=1; index=1
at android.view.WindowManagerGlobal.closeAll(WindowManagerGlobal.java:325)
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3590)
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3756)
at android.app.ActivityThread.access$800(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1286)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5279)
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:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)
Is this a known bug in Android? I have no more information about the crash. Do you have any idea about what can I do to get the cause?
Array index start at 0
you have to subsract 1

Android: WindowManagerGlobal.closeAll() ArrayIndexOutOfBoundsException

While the Android app is working normally on most devices, for some people this error occurs on Galaxy S4:
java.lang.ArrayIndexOutOfBoundsException: length=0; index=0
at android.view.WindowManagerGlobal.closeAll(WindowManagerGlobal.java:325)
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3589)
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3755)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1287)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5293)
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:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)
Does anyone know how to deal with this?

Selecting an item in ListFragment list programmatically

I've made my Android app tablet optimized and I followed the tutorial here:
Everything is great, but I am trying to select an item (say, the 1st item) with a button in the ActionBar.
I tried this answer to use performItemClick but on I've got error reports of java.lang.IllegalStateException
in android.support.v4.app.ListFragment.ensureList, java.lang.IllegalStateException: Content view not yet created, and java.lang.NullPointerException
in android.content.ComponentName.<init>
I've tried checking if the ListView is null and still get the error reports on the Play Store. How do I properly select an item in my list programmatically?
Update to add logcat and the code is virtually identical to the tutorials in the links:
Logcat A:
java.lang.IllegalStateException: Content view not yet created
at android.support.v4.app.ListFragment.ensureList(ListFragment.java:328)
at android.support.v4.app.ListFragment.getListView(ListFragment.java:222)
at com.ccwilcox.meteorshower.MeteorList.showMeteorDetails(MeteorList.java:69)
at com.ccwilcox.meteorshower.MeteorList.onListItemClick(MeteorList.java:62)
at android.support.v4.app.ListFragment$2.onItemClick(ListFragment.java:58)
at android.widget.AdapterView.performItemClick(AdapterView.java:298)
at android.widget.AbsListView.performItemClick(AbsListView.java:1280)
at com.ccwilcox.meteorshower.MainActivity.viewUpcomingEvent(MainActivity.java:648)
at com.ccwilcox.meteorshower.MainActivity.onOptionsItemSelected(MainActivity.java:534)
at android.app.Activity.onMenuItemSelected(Activity.java:2606)
at android.support.v4.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:361)
at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:1045)
at com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:735)
at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:149)
at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:874)
at com.android.internal.view.menu.ActionMenuView.invokeItem(ActionMenuView.java:592)
at com.android.internal.view.menu.ActionMenuItemView.onClick(ActionMenuItemView.java:149)
at android.view.View.performClick(View.java:4222)
at android.view.View$PerformClick.run(View.java:17273)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4895)
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:994)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
at dalvik.system.NativeStart.main(Native Method)
Logcat B:
java.lang.NullPointerException
at android.content.ComponentName.<init>(ComponentName.java:75)
at android.content.Intent.<init>(Intent.java:2874)
at com.ccwilcox.meteorshower.MeteorList.showMeteorDetails(MeteorList.java:86)
at com.ccwilcox.meteorshower.MeteorList.onListItemClick(MeteorList.java:62)
at android.support.v4.app.ListFragment$2.onItemClick(ListFragment.java:58)
at android.widget.AdapterView.performItemClick(AdapterView.java:284)
at android.widget.ListView.performItemClick(ListView.java:3701)
at com.ccwilcox.meteorshower.MainActivity.viewUpcomingEvent(MainActivity.java:648)
at com.ccwilcox.meteorshower.MainActivity.onOptionsItemSelected(MainActivity.java:534)
at android.app.Activity.onMenuItemSelected(Activity.java:2205)
at android.support.v4.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:361)
at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:779)
at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:143)
at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:861)
at com.android.internal.view.menu.IconMenuView.invokeItem(IconMenuView.java:532)
at com.android.internal.view.menu.IconMenuItemView.performClick(IconMenuItemView.java:122)
at android.view.View$PerformClick.run(View.java:9152)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3687)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
at dalvik.system.NativeStart.main(Native Method)
Update 2
And here is the code that is causing the problem:
if (mListFragment.listView != null) {
mListFragment.listView.performItemClick(mListFragment.listView.getAdapter().getView(position, null, null), position, mListFragment.listView.getAdapter().getItemId(position));
}

Categories

Resources