Android safe args 添加android后无法生成应用程序:defaultValue="@空";使用安全参数时

Android safe args 添加android后无法生成应用程序:defaultValue="@空";使用安全参数时,android-safe-args,Android Safe Args,我的应用程序首先将MainFragment加载到UI,单击按钮后,转到NewCodeFragmentUI 在NewCodeFragmentUI上,当单击另一个按钮时,返回到MainFragmentUI,使用Safe Args返回名为newCode的arg 我的问题是,当我运行应用程序时,我得到一个错误,如下所示: <fragment android:id="@+id/mainFragment" android:name="com.cementc

我的应用程序首先将
MainFragment
加载到UI,单击按钮后,转到
NewCodeFragment
UI

NewCodeFragment
UI上,当单击另一个按钮时,返回到
MainFragment
UI,使用
Safe Args
返回名为newCode的arg

我的问题是,当我运行应用程序时,我得到一个错误,如下所示:

<fragment
    android:id="@+id/mainFragment"
    android:name="com.cementcaibird.astock.main.MainFragment"
    android:label="MainFragment" >
    <action
        android:id="@+id/action_mainFragment_to_newCodeFragment"
        app:destination="@id/newCodeFragment" />
    <argument
        android:name="newCode"
        app:argType="string"
        app:nullable="true"
        android:defaultValue="@null" />
</fragment>
错误行:

val newCode = MainFragmentArgs.fromBundle(requireArguments()).newCode
日志信息:

java.lang.IllegalArgumentException: Required argument "newCode" is missing and does not have an android:defaultValue
所以我添加了
android:defaultValue=“@null”
,如下所示:

<fragment
    android:id="@+id/mainFragment"
    android:name="com.cementcaibird.astock.main.MainFragment"
    android:label="MainFragment" >
    <action
        android:id="@+id/action_mainFragment_to_newCodeFragment"
        app:destination="@id/newCodeFragment" />
    <argument
        android:name="newCode"
        app:argType="string"
        app:nullable="true"
        android:defaultValue="@null" />
</fragment>
“生成”信息:

Too many arguments for public open fun actionNewCodeFragmentToMainFragment(): NewCodeFragmentDirections.ActionNewCodeFragmentToMainFragment defined in com.cementcaibird.astock.newcode.NewCodeFragmentDirections