Activity Already attached

一、问题

12-06 09:32:03.528 2525-2525/ly.com.opengles E/AndroidRuntime: FATAL EXCEPTION: main
    Process: ly.com.opengles, PID: 2525
    java.lang.RuntimeException: Unable to start activity ComponentInfo{ly.com.opengles/ly.com.vertex.sample1304.Vertex1304Activity}: java.lang.IllegalStateException: Already attached
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
        at android.app.ActivityThread.-wrap11(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:148)
        at android.app.ActivityThread.main(ActivityThread.java:5417)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
     Caused by: java.lang.IllegalStateException: Already attached
        at androidx.fragment.app.FragmentManagerImpl.attachController(FragmentManagerImpl.java:2563)
        at androidx.fragment.app.FragmentController.attachHost(FragmentController.java:116)
        at androidx.fragment.app.FragmentActivity.onCreate(FragmentActivity.java:284)
        at androidx.appcompat.app.AppCompatActivity.onCreate(AppCompatActivity.java:106)
        at ly.com.vertex.sample1304.Vertex1304Activity.onCreate(Vertex1304Activity.java:22)
        at android.app.Activity.performCreate(Activity.java:6237)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)

二、原因

如下,多次调用 super.onCreate 导致

super.onCreate(savedInstanceState);

三、解决

保证只能有一次 super.onCreate 即可

你可能感兴趣的:(Activity Already attached)