Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash - Attempt to invoke interface method 'boolean android.view.ViewParent.showContextMenuForChild(android.view.View, float, float)' on a null object reference #134

Open
iampankajver opened this issue Oct 8, 2024 · 0 comments

Comments

@iampankajver
Copy link

iampankajver commented Oct 8, 2024

Fatal Exception: java.lang.NullPointerException: Attempt to invoke interface method 'boolean android.view.ViewParent.showContextMenuForChild(android.view.View, float, float)' on a null object reference
      at android.view.View.showContextMenu(View.java:7739)
      at com.mpiannucci.reactnativecontextmenu.ContextMenuView$1.onSingleTapConfirmed(ContextMenuView.java:56)
      at android.view.GestureDetector$GestureHandler.handleMessage(GestureDetector.java:333)
      at android.os.Handler.dispatchMessage(Handler.java:106)
      at android.os.Looper.loopOnce(Looper.java:211)
      at android.os.Looper.loop(Looper.java:300)
      at android.app.ActivityThread.main(ActivityThread.java:8410)
      at java.lang.reflect.Method.invoke(Method.java)
      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:559)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:954)
try {
                            if (getParent() != null) {
                                showContextMenu(e.getX(), e.getY());
                            } else {
                                Log.e("ContextMenuView", "Parent view is null, cannot show context menu.");
                            }
                        } catch (NullPointerException ex) {
                            Log.e("ContextMenuView", "Failed to show context menu due to null reference", ex);
                        }

I am getting the above error in production for some users, currently, I have added the error handling as shown above. Let me know if there is another solution and release the fix in the upcoming version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant