在更改一些代码并在模拟器上重新加载应用程序后测试移动应用程序时,该应用程序崩溃。日志猫显示此错误:“ java.lang.NullPointerException:尝试在空对象引用上调用虚拟方法'boolean java.lang.Object.equals(java.lang.Object)'”
java.lang.RuntimeException: Unable to destroy activity {com.example.cinemaapp/com.example.cinemaapp.ui.activities.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.Object.equals(java.lang.Object)' on a null object reference
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4438)
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:4456)
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4730)
at android.app.ActivityThread.-wrap18(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1599)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.Object.equals(java.lang.Object)' on a null object reference
at androidx.arch.core.internal.SafeIterableMap.get(SafeIterableMap.java:48)
at androidx.arch.core.internal.SafeIterableMap.remove(SafeIterableMap.java:98)
at androidx.lifecycle.LiveData.removeObserver(LiveData.java:225)
at androidx.lifecycle.LiveData$LifecycleBoundObserver.onStateChanged(LiveData.java:373)
at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.java:355)
at androidx.lifecycle.LifecycleRegistry.backwardPass(LifecycleRegistry.java:309)
at androidx.lifecycle.LifecycleRegistry.sync(LifecycleRegistry.java:328)
at androidx.lifecycle.LifecycleRegistry.moveToState(LifecycleRegistry.java:138)
at androidx.lifecycle.LifecycleRegistry.handleLifecycleEvent(LifecycleRegistry.java:124)
at androidx.fragment.app.Fragment.performDestroy(Fragment.java:2692)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1591)
at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1784)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1861)
at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManager.java:3269)
at androidx.fragment.app.FragmentManagerImpl.dispatchDestroy(FragmentManager.java:3260)
at androidx.fragment.app.FragmentController.dispatchDestroy(FragmentController.java:274)
at androidx.fragment.app.FragmentActivity.onDestroy(FragmentActivity.java:419)
at androidx.appcompat.app.AppCompatActivity.onDestroy(AppCompatActivity.java:210)
at android.app.Activity.performDestroy(Activity.java:7177)
at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1248)
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4425)
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:4456)
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4730)
at android.app.ActivityThread.-wrap18(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1599)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)