我在通过导航图文件中声明的深层链接导航到Fragment时遇到了这个随机崩溃。我在项目中使用导航组件库。
堆栈跟踪:
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)
1条答案
按热度按时间1bqhqjot1#
我在我的Activity的onCreate中丢失了
super.onCreate(savedInstanceState)
。超级烦人的是错误描述没有更具体。