If your navigation graph refer to a nested graph via <include />
tag, the generated Directions
class (e.g. AlbumFragmentDirections.actionAlbumToImage
) will have missing arguments even though <arguments />
is available in the nested graph.
To solve this, you need to make redundant <argument />
declaration in the <action />
tag to the <include />
graph.
In the following example, AlbumFragment
have an action to image
(which is a nested <include/>
graph), so it need a redundant <argument />
decleration within the <action />
tag.
<?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/album"
app:startDestination="@id/nav_album">
<fragment
android:id="@+id/nav_album"
android:name="com.luasoftware.journey.view.sub.AlbumFragment"
android:label="Album"
tools:layout="@layout/album" >
<action
android:id="@+id/action_album_to_image"
app:destination="@id/image">
<!-- redundant argument declaration necessary for nested graph -->
<argument
android:name="default"
app:argType="com.luasoftware.journey.model.args.ImageArgs" />
</action>
</fragment>
<include app:graph="@navigation/image" />
</navigation>
image.xml
<?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/image"
app:startDestination="@id/nav_image">
<fragment
android:id="@+id/nav_image"
android:name="com.luasoftware.journey.view.support.ImageFragment"
android:label="Image"
tools:layout="@layout/image" >
<!-- actual argument declaration -->
<argument
android:name="default"
app:argType="com.luasoftware.journey.model.args.ImageArgs" />
</fragment>
</navigation>