title: Navigation Component: Cannot find NavController
body: <p>I am using Navigation Component for navigating in my app. It works fine inside fragments but it fails to find the nav host in the activity that holds the actual navigation host. </p>
  
  <p>I am trying to open a new fragment when the user clicks on FAB, which I included in Main activity's XML. When I call findNavController() it fails to find the controller. The nav host controller is in the XML layout. I can't understand why it fails to find it. </p>
  
  <p>MainActivity </p>
  
  <pre><code>class MainActivity : AppCompatActivity(), OnActivityComponentRequest {
      override fun getTabLayout(): TabLayout {
          return this.tabLayout
      }
  
      override fun getFap(): FloatingActionButton {
          return this.floatingActionButton
      }
  
      private lateinit var tabLayout: TabLayout
      private lateinit var floatingActionButton: FloatingActionButton
  
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          setContentView(R.layout.activity_main)
          setSupportActionBar(toolbar)
          this.tabLayout = tabs
          this.floatingActionButton = fab
  
          fab.setOnClickListener {
  
           it.findNavController().navigate(R.id.addNewWorkoutFragment)
  
          }
      }
  }
  </code></pre>
  
  <p>Activity main XML </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;androidx.coordinatorlayout.widget.CoordinatorLayout
          xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:app="http://schemas.android.com/apk/res-auto"
          xmlns:tools="http://schemas.android.com/tools"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          tools:context=".domain.MainActivity"
          android:animateLayoutChanges="true"&gt;
  
      &lt;com.google.android.material.appbar.AppBarLayout
              android:layout_height="wrap_content"
              android:layout_width="match_parent"
              android:theme="@style/AppTheme.AppBarOverlay"&gt;
  
          &lt;androidx.appcompat.widget.Toolbar
                  android:id="@+id/toolbar"
                  android:layout_width="match_parent"
                  android:layout_height="?attr/actionBarSize"
                  android:background="?attr/colorPrimary"
                  app:layout_scrollFlags="scroll|enterAlways"
                  app:popupTheme="@style/AppTheme.PopupOverlay"/&gt;
  
          &lt;com.google.android.material.tabs.TabLayout
                  android:id="@+id/tabs"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"&gt;
  
              &lt;com.google.android.material.tabs.TabItem
                      android:text="Test 1"
                      android:layout_height="match_parent"
                      android:layout_width="match_parent"/&gt;
  
              &lt;com.google.android.material.tabs.TabItem
                      android:text="Test 2"
                      android:layout_height="match_parent"
                      android:layout_width="match_parent"/&gt;
          &lt;/com.google.android.material.tabs.TabLayout&gt;
  
      &lt;/com.google.android.material.appbar.AppBarLayout&gt;
  
        &lt;fragment
          android:id="@+id/nav_host_fragment"
          android:name="androidx.navigation.fragment.NavHostFragment"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          app:defaultNavHost="true"
          app:navGraph="@navigation/main_navigation" /&gt;
  
  
      &lt;com.google.android.material.bottomappbar.BottomAppBar
              android:id="@+id/bar"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_gravity="bottom"/&gt;
  
  
      &lt;com.google.android.material.floatingactionbutton.FloatingActionButton
              android:id="@+id/fab"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              app:layout_anchorGravity="right|top"
              app:layout_anchor="@+id/bar"
              android:src="@drawable/ic_add_black_24dp"/&gt;
  
  &lt;/androidx.coordinatorlayout.widget.CoordinatorLayout&gt;
  </code></pre>