title: Need help: navGraph, setSupportActionBar, navController, viewBinding kotlin
body: <p>I am amater android develop, this code I got this code from youtube channel by Philipp Lackner, which was written 2 years ago, but it no actulity now, but not relevant now, I had to change it a bit.</p>
  <p>I couldn't figure out on my own what I did wrong. The application throws out after activation:</p>
  <p><em>activity_main.xml</em></p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;androidx.constraintlayout.widget.ConstraintLayout 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/rootView&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;&gt;
  
      &lt;com.google.android.material.appbar.AppBarLayout
          android:id=&quot;@+id/appBarLayout&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;?android:attr/actionBarSize&quot;
          app:layout_constraintEnd_toEndOf=&quot;parent&quot;
          app:layout_constraintHorizontal_bias=&quot;0.5&quot;
          app:layout_constraintStart_toStartOf=&quot;parent&quot;
          app:layout_constraintTop_toTopOf=&quot;parent&quot;&gt;
  
          &lt;com.google.android.material.appbar.MaterialToolbar
              android:id=&quot;@+id/toolbar&quot;
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;match_parent&quot;&gt;
  
              &lt;com.google.android.material.textview.MaterialTextView
                  android:id=&quot;@+id/tvToolbarTitle&quot;
                  android:layout_width=&quot;match_parent&quot;
                  android:layout_height=&quot;match_parent&quot;
                  android:gravity=&quot;center_vertical&quot;
                  android:text=&quot;Running App&quot;
                  android:textColor=&quot;@android:color/white&quot;
                  android:textSize=&quot;30sp&quot;
                  android:textStyle=&quot;bold&quot;
                  app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
                  app:layout_constraintEnd_toEndOf=&quot;parent&quot;
                  app:layout_constraintHorizontal_bias=&quot;0.5&quot;
                  app:layout_constraintStart_toStartOf=&quot;parent&quot;
                  app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt;
  
          &lt;/com.google.android.material.appbar.MaterialToolbar&gt;
      &lt;/com.google.android.material.appbar.AppBarLayout&gt;
  
      &lt;FrameLayout
          android:id=&quot;@+id/flFragment&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;0dp&quot;
          app:layout_constraintBottom_toTopOf=&quot;@+id/bottomNavigationView&quot;
          app:layout_constraintEnd_toEndOf=&quot;parent&quot;
          app:layout_constraintStart_toStartOf=&quot;parent&quot;
          app:layout_constraintTop_toBottomOf=&quot;@+id/appBarLayout&quot;&gt;
          &lt;fragment
              android:id=&quot;@+id/navHostFragment&quot;
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;match_parent&quot;
              android:name=&quot;androidx.navigation.fragment.NavHostFragment&quot;
              app:defaultNavHost=&quot;true&quot;
              app:navGraph=&quot;@navigation/nav_graph&quot;/&gt;
  
  
      &lt;/FrameLayout&gt;
  
      &lt;com.google.android.material.bottomnavigation.BottomNavigationView
          android:id=&quot;@+id/bottomNavigationView&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;56dp&quot;
          app:itemIconTint=&quot;@drawable/bottom_nav_selector&quot;
          app:itemTextColor=&quot;@drawable/bottom_nav_selector&quot;
          app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
          app:layout_constraintEnd_toEndOf=&quot;parent&quot;
          app:layout_constraintHorizontal_bias=&quot;0.5&quot;
          app:layout_constraintStart_toStartOf=&quot;parent&quot; /&gt;
  
  
  &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  </code></pre>
  <p>MainActivity.kt</p>
  <pre><code>package com.example.runningapp.ui
  
  import android.os.Bundle
  import android.view.View
  import androidx.appcompat.app.AppCompatActivity
  import androidx.navigation.fragment.NavHostFragment
  import androidx.navigation.fragment.findNavController
  import androidx.navigation.ui.setupWithNavController
  import com.example.runningapp.R
  import com.example.runningapp.databinding.ActivityMainBinding
  import dagger.hilt.android.AndroidEntryPoint
  
  
  @AndroidEntryPoint
  class MainActivity : AppCompatActivity() {
  
      private lateinit var binding: ActivityMainBinding
  
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          binding = ActivityMainBinding.inflate(layoutInflater)
          val view = binding.root
          setContentView(view)
  
          setSupportActionBar(binding.toolbar)
  
  
          val navHostFragment = supportFragmentManager.findFragmentById(R.id.navHostFragment) as NavHostFragment
          val navController = navHostFragment.navController
          val navGraph = navController.navInflater.inflate(R.navigation.nav_graph)
          navController.graph = navGraph
          binding.bottomNavigationView.setupWithNavController(navHostFragment.findNavController())
          navHostFragment.findNavController()
              .addOnDestinationChangedListener{_, destination,_ -&gt;
               when(destination.id) {
              R.id.settingsFragment, R.id.runFragment, R.id.statisticsFragment -&gt;
                  binding.bottomNavigationView.visibility = View.VISIBLE
                   else -&gt;binding.bottomNavigationView.visibility = View.GONE
                   }
              }
  </code></pre>