gpt4 book ai didi

onCreate 的 java.lang.NoSuchMethodException

转载 作者:行者123 更新时间:2023-12-04 18:55:39 25 4
gpt4 key购买 nike

我在 Google Play 崩溃日志中看到了崩溃,这让我非常难过。

java.lang.RuntimeException: 
at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3086)
at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:3229)
at android.app.servertransaction.LaunchActivityItem.execute (LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks (TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1926)
at android.os.Handler.dispatchMessage (Handler.java:106)
at android.os.Looper.loop (Looper.java:214)
at android.app.ActivityThread.main (ActivityThread.java:6981)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1445)
Caused by: androidx.fragment.app.Fragment$InstantiationException:
at androidx.fragment.app.Fragment.instantiate (Fragment.java:462)
at androidx.fragment.app.FragmentContainer.instantiate (FragmentContainer.java:50)
at androidx.fragment.app.FragmentState.instantiate (FragmentState.java:80)
at androidx.fragment.app.FragmentManagerImpl.restoreAllState (FragmentManager.java:3109)
at androidx.fragment.app.FragmentController.restoreAllState (FragmentController.java:158)
at androidx.fragment.app.FragmentActivity.onCreate (FragmentActivity.java:344)
at androidx.appcompat.app.AppCompatActivity.onCreate (AppCompatActivity.java:85)
at com.autotask.jbarra.kotlinmvvm.MainActivity.onCreate (MainActivity.kt:102)
at android.app.Activity.performCreate (Activity.java:7326)
at android.app.Activity.performCreate (Activity.java:7317)
at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3066)

Caused by: java.lang.NoSuchMethodException:
at java.lang.Class.getConstructor0 (Class.java:2328)
at java.lang.Class.getConstructor (Class.java:1725)
at androidx.fragment.app.Fragment.instantiate (Fragment.java:443)

问题是,主要 Activity 的第 102 行并没有什么特别之处
    override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) //This is line 102

什么可能导致这种情况?为什么 oncreate 没有抛出这样的方法?它发生在一些用户的设备上,我无法重现它。

最佳答案

Activity 正在从实例状态包中恢复。还原操作的一部分是重新创建其 fragment 。

您的 Activity 有一个 fragment ,而 fragment 类没有框架所需的 0-arg 构造函数。

关于onCreate 的 java.lang.NoSuchMethodException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56668934/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com