IllegalArgumentException in global navigation

22 views Asked by At

I'm using jetpack navigation, but when I try to do a global navigation, I got an IllegalArgumentException:

java.lang.IllegalArgumentException: Navigation action/destination com.myexample:id/action_global_3 cannot be found from the current destination Destination(com.myexample:id/AFragment)

My navigation graphs:

<?xml version="1.0" encoding="utf-8"?>
<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/first"
    app:startDestination="@id/AFragment">

    <fragment
        android:id="@+id/AFragment"
        android:name="com.myexample.AFragment">
    </fragment>

    <include app:graph="@navigation/second" />
</navigation>
<?xml version="1.0" encoding="utf-8"?>
<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/second"
    app:startDestination="@id/CFragment">

    <fragment
        android:id="@+id/CFragment"
        android:name="com.myexample.CFragment">
    </fragment>
        
    <fragment
        android:id="@+id/BFragment"
        android:name="com.myexample.BFragment">
    </fragment>
    
   <action
        android:id="@+id/action_global_3"
        app:destination="@id/BFragment" />
    
</navigation>

The call from FragmentA:

NavHostFragment.findNavController(this).navigate(SecondDirections.actionGlobal3())
0

There are 0 answers