1

I'm trying to pass a Parcelable argument to a nested graph, but the generated function takes 0 arguments.

I found this thread and I can't see the difference between what I have and what they have.

This is my XML, I removed code to show just the problem

logged_content_nav_graph.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/logged_content_nav_graph"
    app:startDestination="@id/chooseCategoryFragment">

    <fragment
        android:id="@+id/productDetailFragment"
        android:name="com.vendyapp.vendy.features.loggedcontent.productdetail.ui.ProductDetailFragment"
        android:label="fragment_product_detail"
        tools:layout="@layout/fragment_product_detail" >
        <action
            android:id="@+id/action_productDetailFragment_to_loginAndRegisterFragment"
            app:destination="@id/login_nav_graph" />
        <argument
            android:name="product"
            app:argType="com.vendyapp.vendy.features.loggedcontent.home.Product" />
    </fragment>

    <include app:graph="@navigation/login_nav_graph"/>

login_nav_graph.xml (NESTED)

<?xml version="1.0" encoding="utf-8"?>
<navigation android:id="@+id/login_nav_graph"
    app:startDestination="@id/loginAndRegisterFragment"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <fragment
        android:id="@+id/loginAndRegisterFragment"
        android:name="com.vendyapp.vendy.features.login.ui.LoginAndRegisterFragment"
        android:label="fragment_login_and_register"
        tools:layout="@layout/fragment_login_and_register">
        <argument
            android:name="product"
            app:argType="com.vendyapp.vendy.features.loggedcontent.home.Product"
            app:nullable="true" />
        <action
            android:id="@+id/action_loginAndRegisterFragment_to_registerFragment"
            app:destination="@id/registerFragment" />
        <action
            android:id="@+id/action_loginAndRegisterFragment_to_loginFragment"
            app:destination="@id/loginFragment" />

    </fragment>
</navigation>

With the nav graphs like this, in my Kotlin class I do

            val action = ProductDetailFragmentDirections.actionProductDetailFragmentToLoginAndRegisterFragment(product)
            findNavController().navigate(action)

But it says this function takes 0 arguments.

What am I getting wrong? Thanks in advance.

0 Answers0