title: Android: Fragment has null arguments when getting global nested safeargs
body: <p>I am trying to get my <code>safeargs</code> within the second fragment <code>(calibrateRepairOptionFragment)</code> of my <code>nested_graph</code>, The problem is that I get the above written error <code>Fragment CalibrateRepairOptionFragment{5e1268d} (c7c2906d-5a17-4d22-b41d-eefe8eee059f) id=0x7f09012d} has null arguments</code>.</p>
  <p>I am confused because when I try to get my <code>safeargs</code> in the first fragment <code>(CalibrateRepairMessageFragment)</code>, everything works and the toolbar_title is not null.</p>
  <h2>BaseFragment (getting safeargs here)</h2>
  <pre><code>abstract class NewBaseEmailFragment&lt;out VB: ViewDataBinding&gt;(
      private val layout: Int,
      private val next: Int,
  ) : Fragment(layout) {
      abstract val viewModel: ViewModel
      private val toolbarTitleArgs by navArgs&lt;NavSendEmailArgs&gt;()
  
      override fun onCreateView(
          inflater: LayoutInflater,
          container: ViewGroup?,
          savedInstanceState: Bundle?
      ): View? = DataBindingUtil.inflate&lt;VB&gt;(inflater, layout, container, false).apply {
          lifecycleOwner = viewLifecycleOwner
          setVariable(BR.viewModel, viewModel)
      }.root
  
      override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
          super.onViewCreated(view, savedInstanceState)
          initToolbar()
      }
  
      // Using safeargs here, everything fine in the first fragment of the nested graph
      private fun initToolbar() = with(toolbar) {
          setupWithNavController(findNavController(), AppBarConfiguration(findNavController().graph))
          toolbar_title.text = toolbarTitleArgs.toolbarTitle
      }
  }
  </code></pre>
  <h2>First Fragment (no error here, toolbar is set correctly)</h2>
  <pre><code>@AndroidEntryPoint
  class CalibrateRepairMessageFragment : NewBaseEmailFragment&lt;FragmentCalibrateRepairUserDataBinding&gt;(
      R.layout.fragment_calibrate_repair_message,
      R.id.action_calibrateRepairMessageFragment_to_calibrateRepairOptionFragment,
   ) {
      override val viewModel: EmailViewModel by navGraphViewModels(R.id.nav_send_email) { defaultViewModelProviderFactory }
  
      override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
          super.onViewCreated(view, savedInstanceState)
      }
  }
  </code></pre>
  <h2>Second Fragment (getting error here, toolbar.title is null)</h2>
  <pre><code>@AndroidEntryPoint
  class CalibrateRepairOptionFragment : NewBaseEmailFragment&lt;FragmentCalibrateRepairOptionBinding&gt;(
      R.layout.fragment_calibrate_repair_option,
      R.id.action_calibrateRepairOptionFragment_to_calibrateRepairUserDataFragment,
  ) {
      override val viewModel: EmailViewModel by navGraphViewModels(R.id.nav_send_email) { defaultViewModelProviderFactory }
  
      override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
          super.onViewCreated(view, savedInstanceState)
      }
  }
  </code></pre>
  <h2>nav_main.xml</h2>
  <pre><code>&lt;!-- Sending arguments from homeFragment to nested Graph &quot;nav_send_email&quot; --&gt;
  &lt;fragment
      android:id=&quot;@+id/homeFragment&quot;
      android:name=&quot;com.example.app.framework.ui.view.fragments.home.HomeFragment&quot;
      tools:layout=&quot;@layout/fragment_home&quot;&gt;
  
      &lt;action
          android:id=&quot;@+id/action_homeFragment_to_nav_send_email&quot;
          app:destination=&quot;@id/nav_send_email&quot;&gt;
      &lt;/action&gt;
  &lt;/fragment&gt;
  &lt;!-- NESTED GRAPH &quot;nav_send_mail&quot; ---&gt;
  &lt;navigation
      android:id=&quot;@+id/nav_send_email&quot;
      app:startDestination=&quot;@id/calibrateRepairMessageFragment&quot;&gt;
      &lt;!-- Global argument for entire nested graph --&gt;
      &lt;argument
          android:name=&quot;toolbar_title&quot;
          app:argType=&quot;string&quot;
          app:nullable=&quot;false&quot; /&gt;
  
      &lt;!-- Getting safeargs here is no problem! (first fragment) --&gt;
      &lt;fragment
          android:id=&quot;@+id/calibrateRepairMessageFragment&quot;
          android:name=&quot;com.example.app.framework.ui.view.fragments.home.calibrateAndRepair.CalibrateRepairMessageFragment&quot;
          tools:layout=&quot;@layout/fragment_calibrate_repair_message&quot;&gt;
          &lt;argument
              android:name=&quot;toolbar_title&quot;
              app:argType=&quot;string&quot;
              app:nullable=&quot;false&quot; /&gt;
          &lt;action
              android:id=&quot;@+id/action_calibrateRepairMessageFragment_to_calibrateRepairOptionFragment&quot;
              app:destination=&quot;@id/calibrateRepairOptionFragment&quot; /&gt;
      &lt;/fragment&gt;
  
      &lt;!-- Can't get safeargs here, safeargs is null (second fragment) --&gt;
      &lt;fragment
          android:id=&quot;@+id/calibrateRepairOptionFragment&quot;
          android:name=&quot;com.example.app.framework.ui.view.fragments.home.calibrateAndRepair.CalibrateRepairOptionFragment&quot;
          tools:layout=&quot;@layout/fragment_calibrate_repair_data_overview&quot;&gt;
          &lt;action
              android:id=&quot;@+id/action_calibrateRepairOptionFragment_to_calibrateRepairUserDataFragment&quot;
              app:destination=&quot;@id/calibrateRepairUserDataFragment&quot; /&gt;
      &lt;/fragment&gt;
     
  &lt;/navigation&gt;
  </code></pre>
  <h2>Full Stracktrace</h2>
  <pre><code> java.lang.IllegalStateException: Fragment CalibrateRepairOptionFragment{5e1268d} (c7c2906d-5a17-4d22-b41d-eefe8eee059f) id=0x7f09012d} has null arguments
          at com.example.app.framework.ui.view.fragments.home.refactor.NewBaseEmailFragment$$special$$inlined$navArgs$1.invoke(FragmentNavArgsLazy.kt:42)
          at com.example.app.framework.ui.view.fragments.home.refactor.NewBaseEmailFragment$$special$$inlined$navArgs$1.invoke(Unknown Source:0)
          at androidx.navigation.NavArgsLazy.getValue(NavArgsLazy.kt:44)
          at androidx.navigation.NavArgsLazy.getValue(NavArgsLazy.kt:34)
          at com.example.app.framework.ui.view.fragments.home.refactor.NewBaseEmailFragment.getToolbarTitleArgs(Unknown Source:4)
          at com.example.app.framework.ui.view.fragments.home.refactor.NewBaseEmailFragment.initToolbar(NewBaseEmailFragment.kt:59)
          at com.example.app.framework.ui.view.fragments.home.refactor.NewBaseEmailFragment.onViewCreated(NewBaseEmailFragment.kt:47)
          at com.example.app.framework.ui.view.fragments.home.calibrateAndRepair.CalibrateRepairOptionFragment.onViewCreated(CalibrateRepairOptionFragment.kt:23)
          at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:332)
          at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1199)
          at androidx.fragment.app.FragmentManager.addAddedFragments(FragmentManager.java:2236)
          at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:2009)
          at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1965)
          at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1861)
          at androidx.fragment.app.FragmentManager$4.run(FragmentManager.java:413)
          at android.os.Handler.handleCallback(Handler.java:883)
          at android.os.Handler.dispatchMessage(Handler.java:100)
          at android.os.Looper.loop(Looper.java:214)
          at android.app.ActivityThread.main(ActivityThread.java:7356)
          at java.lang.reflect.Method.invoke(Native Method)
          at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
  </code></pre>