0

I am getting below viewTreeObserver crash on firebase. What could be the possible cause? ViewTreeObserver is used at multiple places in the app so unsure where exactly this crash is happening

Fatal Exception: java.lang.NullPointerException: Attempt to invoke interface method 'void android.view.ViewTreeObserver$OnGlobalLayoutListener.onGlobalLayout()' on a null object reference
       at android.view.ViewTreeObserver.dispatchOnGlobalLayout(ViewTreeObserver.java:1056)
       at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3050)
       at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2075)
       at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8471)
       at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1065)
       at android.view.Choreographer.doCallbacks(Choreographer.java:889)
       at android.view.Choreographer.doFrame(Choreographer.java:816)
       at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1050)
       at android.os.Handler.handleCallback(Handler.java:883)
       at android.os.Handler.dispatchMessage(Handler.java:100)
       at android.os.Looper.loop(Looper.java:237)
       at android.app.ActivityThread.main(ActivityThread.java:7824)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:512)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1027)

1 Answer 1

0

If an application keeps a long-lived reference to a ViewTreeObserver, it should always check for the result of isAlive() before calling any other method.

See https://developer.android.com/reference/android/view/ViewTreeObserver#isAlive()

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.