当前位置:网站首页>Fragment addition failed error lookup

Fragment addition failed error lookup

2022-07-05 05:15:00 ximen502_

Find the reason according to the source code

Caused by: java.lang.IllegalArgumentException: No view found for id 0x7f0801a1 (com.exam.starseat:id/fl_out) for fragment StarFragment{
    92bd796 (d41094b9-f8de-4eb5-9064-e75ab80d61b7) id=0x7f0801a1}
        at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:875)
        at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238)
        at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1303)
        at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:439)
        at androidx.fragment.app.FragmentManagerImpl.executeOps(FragmentManagerImpl.java:2079)
        at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1869)
        at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1824)
        at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1727)
        at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManagerImpl.java:2663)
        at androidx.fragment.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManagerImpl.java:2613)
        at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:246)
        at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:542)
        at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:210)
        at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1334)
        at android.app.Activity.performStart(Activity.java:7067)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2819)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2931) 
        at android.app.ActivityThread.-wrap11(Unknown Source:0) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1620) 
        at android.os.Handler.dispatchMessage(Handler.java:105) 
        at android.os.Looper.loop(Looper.java:176) 
        at android.app.ActivityThread.main(ActivityThread.java:6701) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:249) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:783) 

fragment Add failure
 Error code location Class inheritance relation
 Insert picture description here

onFindViewById In the end in FragmentActivity To implement inside ,activity The implementation is as follows :
 Insert picture description here Called fragmentActivity Self findViewById(int id) Method , This method is in the parent class Activity Is implemented as follows :
 Insert picture description here Method call again Window In abstract classes ,Window The implementation is as follows
 Insert picture description here If you use a not activity In the layout ViewGroup(FrameLayout) Add Fragment It's a mistake to report when you're in trouble , The crash error is shown at the beginning of the article .
Reference blog :https://blog.csdn.net/hwliu51/article/details/69841068#t0

Slightly rough typesetting

原网站

版权声明
本文为[ximen502_]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202140623325243.html