'NullPointerException on FragmentHostCallback.getContext()
I'm facing this random crash while navigating to a Fragment via deep-link which is declared in the navigation graph file. I'm using navigation component library in my project.
Stacktrace:
Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Context androidx.fragment.app.FragmentHostCallback.getContext()' on a null object reference
at androidx.fragment.app.FragmentLifecycleCallbacksDispatcher.dispatchOnFragmentPreAttached(FragmentLifecycleCallbacksDispatcher.java:91)
at androidx.fragment.app.FragmentLifecycleCallbacksDispatcher.dispatchOnFragmentPreAttached(FragmentLifecycleCallbacksDispatcher.java:96)
at androidx.fragment.app.FragmentStateManager.attach(FragmentStateManager.java:463)
at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:275)
at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:2189)
at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:2106)
at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:2002)
at androidx.fragment.app.FragmentManager$5.run(FragmentManager.java:524)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7698)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:952)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|