google / iosched

The Google I/O Android App
Apache License 2.0
21.77k stars 6.2k forks source link

java.lang.IllegalStateException: No instantiated fragment #414

Open shea-sy opened 2 years ago

shea-sy commented 2 years ago

I stumbled across a strange problem that can cause a program to crash. if I change the theme of the application after frequently switching the bottom navigation bar, I have a chance to crash the program. The following is the crash information.

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.google.samples.apps.iosched/com.google.samples.apps.iosched.ui.MainActivity}: java.lang.IllegalStateException: No instantiated fragment for (e1bb8664-5a58-42d2-89c4-50a9909215e1)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3759)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3933)
    at android.app.ActivityThread.handleRelaunchActivityInner(ActivityThread.java:5908)
    at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:5800)
    at android.app.servertransaction.ActivityRelaunchItem.execute(ActivityRelaunchItem.java:71)
    at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
    at android.app.ClientTransactionHandler.executeTransaction(ClientTransactionHandler.java:65)
    at android.app.ActivityThread.handleRelaunchActivityLocally(ActivityThread.java:5867)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2292)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loopOnce(Looper.java:210)
    at android.os.Looper.loop(Looper.java:299)
    at android.app.ActivityThread.main(ActivityThread.java:8212)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:556)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1045)
Caused by: java.lang.IllegalStateException: No instantiated fragment for (e1bb8664-5a58-42d2-89c4-50a9909215e1)
    at androidx.fragment.app.FragmentStore.restoreAddedFragments(FragmentStore.java:61)
    at androidx.fragment.app.FragmentManager.restoreSaveStateInternal(FragmentManager.java:2449)
    at androidx.fragment.app.Fragment.restoreChildFragmentState(Fragment.java:1934)
    at androidx.fragment.app.Fragment.onCreate(Fragment.java:1911)
    at androidx.navigation.fragment.NavHostFragment.onCreate(NavHostFragment.kt:169)
    at androidx.fragment.app.Fragment.performCreate(Fragment.java:2981)
    at androidx.fragment.app.FragmentStateManager.create(FragmentStateManager.java:474)
    at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:257)
    at androidx.fragment.app.FragmentStore.moveToExpectedState(FragmentStore.java:113)
    at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1374)
    at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:2841)
    at androidx.fragment.app.FragmentManager.dispatchCreate(FragmentManager.java:2773)
    at androidx.fragment.app.FragmentController.dispatchCreate(FragmentController.java:251)
    at androidx.fragment.app.FragmentActivity.onCreate(FragmentActivity.java:252)
    at com.google.samples.apps.iosched.ui.MainActivity.onCreate(MainActivity.kt:120)
    at android.app.Activity.performCreate(Activity.java:8278)
    at android.app.Activity.performCreate(Activity.java:8242)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1341)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3739)
    ... 17 more