Error when use FragmentContainerView and NavHostFragment

Viewed 146

This is my code in xml,

<androidx.fragment.app.FragmentContainerView
        android:id="@+id/nav_auth_fragment"
        android:name="androidx.navigation.fragment.NavHostFragment"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:defaultNavHost="true"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:navGraph="@navigation/nav_graph_auth" />

And I have Exception

Caused by: android.view.InflateException: Binary XML file line #9 in activity_auth: Binary XML file line #9 in activity_auth: Error inflating class androidx.fragment.app.FragmentContainerView
 Caused by: android.view.InflateException: Binary XML file line #9 in activity_auth: Error inflating class androidx.fragment.app.FragmentContainerView
 Caused by: java.lang.IllegalStateException: FragmentContainerView must have an android:id to add Fragment androidx.navigation.fragment.NavHostFragment

Help me please, and thank!

0 Answers
Related