title: Trying to use NavHostFragment and im getting an error: Error inflating class androidx.fragment.app.FragmentContainerView
body: <p>here is the caused by:
  &quot; Caused by: android.view.InflateException: Binary XML file line #21 in com.example.dnaire:layout/main: Binary XML file line #21 in com.example.dnaire:layout/main: Error inflating class androidx.fragment.app.FragmentContainerView
  Caused by: android.view.InflateException: Binary XML file line #21 in com.example.dnaire:layout/main: Error inflating class androidx.fragment.app.FragmentContainerView
  Caused by: java.lang.reflect.InvocationTargetException&quot;</p>
  <p>I don't have much code yet in the project, just started it.</p>
  <p>here is the Main activity:</p>
  <pre><code>class Main : Activity() {
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          val mainBinding = MainBinding.inflate(layoutInflater)
          setContentView(mainBinding.root)
      }
  }
  </code></pre>
  <p>that is the main.xml file that contains the FragmentContainerView that causes the problem:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;layout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
      xmlns:tools=&quot;http://schemas.android.com/tools&quot;&gt;
      &lt;androidx.constraintlayout.widget.ConstraintLayout
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;match_parent&quot;
          tools:context=&quot;.Main&quot;&gt;
  
          &lt;androidx.fragment.app.FragmentContainerView
              android:id=&quot;@+id/nav_host_fragment&quot;
              android:name=&quot;androidx.navigation.fragment.NavHostFragment&quot;
              android:layout_width=&quot;0dp&quot;
              android:layout_height=&quot;0dp&quot;
              app:layout_constraintLeft_toLeftOf=&quot;parent&quot;
              app:layout_constraintRight_toRightOf=&quot;parent&quot;
              app:layout_constraintTop_toTopOf=&quot;parent&quot;
              app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
              app:defaultNavHost=&quot;true&quot;
              app:navGraph=&quot;@navigation/nav_graph&quot; /&gt;
  
      &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  &lt;/layout&gt;
  </code></pre>
  <p>that is the nav_graph.xml file</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;navigation xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
      xmlns:tools=&quot;http://schemas.android.com/tools&quot;
      android:id=&quot;@+id/nav_graph&quot;
      app:startDestination=&quot;@id/startFragment&quot;&gt;
  
      &lt;fragment
          android:id=&quot;@+id/startFragment&quot;
          android:name=&quot;com.example.dnaire.login.StartFragment&quot;
          android:label=&quot;fragment_start&quot;
          tools:layout=&quot;@layout/fragment_start&quot; /&gt;
  &lt;/navigation&gt;
  </code></pre>