title: Android Navigation Component back button not working
body: <p>I'm using the Navigation Component in android where I have set 6 fragments initially. The problem is when I added a new fragment (ProfileFragment). </p>
  
  <p>When I navigate to this new fragment from the start destination, pressing the native back button does not pop the current fragment off. Instead, it just stays to the fragment I'm in - the back button does nothing.</p>
  
  <p>Here's my <strong>navigation.xml</strong>:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;navigation 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:id="@+id/dashboard_navigation"
      app:startDestination="@id/dashboardFragment"
      &gt;
  
                  &lt;fragment
                      android:id="@+id/dashboardFragment"
                      android:name="com.devssocial.localodge.ui.dashboard.ui.DashboardFragment"
                      android:label="DashboardFragment"
                      &gt;
                                  &lt;action
                                      android:id="@+id/action_dashboardFragment_to_newPostFragment"
                                      app:destination="@id/newPostFragment"
                                      app:enterAnim="@anim/slide_in_up"
                                      app:exitAnim="@anim/slide_out_down"
                                      app:popEnterAnim="@anim/slide_in_up"
                                      app:popExitAnim="@anim/slide_out_down"
                                      /&gt;
                                  &lt;action
                                      android:id="@+id/action_dashboardFragment_to_notificationsFragment"
                                      app:destination="@id/notificationsFragment"
                                      app:enterAnim="@anim/slide_in_up"
                                      app:exitAnim="@anim/slide_out_down"
                                      app:popEnterAnim="@anim/slide_in_up"
                                      app:popExitAnim="@anim/slide_out_down"
                                      /&gt;
                                  &lt;action
                                      android:id="@+id/action_dashboardFragment_to_mediaViewer"
                                      app:destination="@id/mediaViewer"
                                      app:enterAnim="@anim/slide_in_up"
                                      app:exitAnim="@anim/slide_out_down"
                                      app:popEnterAnim="@anim/slide_in_up"
                                      app:popExitAnim="@anim/slide_out_down"
                                      /&gt;
                                  &lt;action
                                      android:id="@+id/action_dashboardFragment_to_postDetailFragment"
                                      app:destination="@id/postDetailFragment"
                                      app:enterAnim="@anim/slide_in_up"
                                      app:exitAnim="@anim/slide_out_down"
                                      app:popEnterAnim="@anim/slide_in_up"
                                      app:popExitAnim="@anim/slide_out_down"
                                      /&gt;
  
                              ====================== HERE'S THE PROFILE ACTION ====================                                
                                  &lt;action
                                      android:id="@+id/action_dashboardFragment_to_profileFragment"
                                      app:destination="@id/profileFragment"
                                      app:enterAnim="@anim/slide_in_up"
                                      app:exitAnim="@anim/slide_out_down"
                                      app:popEnterAnim="@anim/slide_in_up"
                                      app:popExitAnim="@anim/slide_out_down"
                                      /&gt;
                              =====================================================================                                
  
                  &lt;/fragment&gt;
  
  
  
                  &lt;fragment
                      android:id="@+id/profileFragment"
                      android:name="com.devssocial.localodge.ui.profile.ui.ProfileFragment"
                      android:label="fragment_profile"
                      tools:layout="@layout/fragment_profile"
                      /&gt;
  &lt;/navigation&gt;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/qFxgi.png" rel="noreferrer"><img src="https://i.stack.imgur.com/qFxgi.png" alt="enter image description here"></a></p>
  
  <p>In the image above, the highlighted arrow (in the left) is the navigation action I'm having troubles with.</p>
  
  <p>In my <strong>Fragment</strong> code, I'm navigating as follows:</p>
  
  <pre><code>findNavController().navigate(R.id.action_dashboardFragment_to_profileFragment)
  </code></pre>
  
  <p>The other navigation actions are working as intended. But for some reason, this newly added fragment does not behave as intended.</p>
  
  <p>There are no logs showing when I navigate to ProfileFragment and when I press the back button. </p>
  
  <p>Am I missing something? or is there anything wrong with my action/fragment configurations?</p>
  
  <p>EDIT:
  I do not do anything in <strong>ProfileFragment</strong>. Here's the code for it:</p>
  
  <pre><code>class ProfileFragment : Fragment() {
  
      override fun onCreateView(
          inflater: LayoutInflater, container: ViewGroup?,
          savedInstanceState: Bundle?
      ): View? {
          // Inflate the layout for this fragment
          return inflater.inflate(R.layout.fragment_profile, container, false)
      }
  
  
  }
  </code></pre>
  
  <p>And my <strong>activity xml</strong> containing the nav host:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;FrameLayout
          xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:app="http://schemas.android.com/apk/res-auto"
          android:layout_width="match_parent"
          android:layout_height="match_parent"&gt;
  
      &lt;fragment
              android:id="@+id/dashboard_navigation"
              app:layout_behavior="@string/appbar_scrolling_view_behavior"
              android:name="androidx.navigation.fragment.NavHostFragment"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              app:navGraph="@navigation/dashboard_navigation"
              app:defaultNavHost="true"/&gt;
  
  &lt;/FrameLayout&gt;
  </code></pre>