Android X 迁移 - 应用程序启动时崩溃

问题描述 投票:0回答:0

我在将应用程序迁移到 android X 时遇到问题。有什么想法吗?应用程序启动时崩溃,但出现以下异常:

  --- End of managed Java.Lang.IllegalStateException stack trace ---
java.lang.IllegalStateException: You can consumeRestoredStateForKey only after super.onCreate of corresponding component
    at androidx.savedstate.SavedStateRegistry.consumeRestoredStateForKey(SavedStateRegistry.kt:72)
    at androidx.savedstate.Recreator.onStateChanged(Recreator.kt:34)
    at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.kt:314)
    at androidx.lifecycle.LifecycleRegistry.forwardPass(LifecycleRegistry.kt:251)
    at androidx.lifecycle.LifecycleRegistry.sync(LifecycleRegistry.kt:287)
    at androidx.lifecycle.LifecycleRegistry.moveToState(LifecycleRegistry.kt:136)
    at androidx.lifecycle.LifecycleRegistry.handleLifecycleEvent(LifecycleRegistry.kt:119)
    at androidx.lifecycle.ReportFragment$Companion.dispatch$lifecycle_runtime_release(ReportFragment.kt:192)
    at androidx.lifecycle.ReportFragment$LifecycleCallbacks.onActivityPostCreated(ReportFragment.kt:115)
    at android.app.Activity.dispatchActivityPostCreated(Activity.java:1222)
    at android.app.Activity.performCreate(Activity.java:7848)
    at android.app.Activity.performCreate(Activity.java:7828)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3251)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3415)
    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2022)
    at android.os.Handler.dispatchMessage(Handler.java:107)
    at android.os.Looper.loop(Looper.java:235)
    at android.app.ActivityThread.main(ActivityThread.java:7441)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
android fragment androidx
© www.soinside.com 2019 - 2024. All rights reserved.