0

I encountered an error when trying to generate a navigation action (generated by the safeargs gradle plugin). Source and target fragments are both bottomsheetdialogfragments and therefore registered as dialogs in the corresponding navigation graph.
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/action_map_receipt_nav_graph"
    app:startDestination="@id/paymentAccountsDialogFragment">

    <dialog
        android:id="@+id/paymentAccountsDialogFragment"
        android:name="de.sevdesk.payments.ui.paymentAccounts.dialog.PaymentAccountsDialogFragment"
        android:label="payment_accounts_dialog_fragment" >
        <action
            android:id="@+id/action_paymentAccountsDialogFragment_to_accountTransactionsDialogFragment"
            app:destination="@id/accountTransactionsDialogFragment" />
    </dialog>

    <dialog
        android:id="@+id/accountTransactionsDialogFragment"
        android:name="de.sevdesk.payments.ui.accountTransactions.dialog.AccountTransactionsDialogFragment"
        android:label="AccountTransactionsDialogFragment">
        <argument
            android:name="checkAccountId"
            app:argType="string" />
        <argument
            android:name="checkAccountName"
            app:argType="string" />
    </dialog>

</navigation>

The navigation itself looks like this

val action = PaymentAccountsDialogFragmentDirections.actionPaymentAccountsDialogFragmentToAccountTransactionsDialogFragment(
    it.checkAccountId,
    it.checkAccountName
)

findNavController().navigate(action)

This results in a runtime exception:

2021-03-01 13:16:50.208 8888-8888/de.mypck.myapp E/AndroidRuntime: FATAL EXCEPTION: main
    Process: de.mypck.myapp, PID: 8888
    java.lang.NoSuchMethodError: No virtual method actionPaymentAccountsDialogFragmentToAccountTransactionsDialogFragment(Ljava/lang/String;Ljava/lang/String;)Landroidx/navigation/NavDirections; in class Lde/mypck/payments/ui/paymentAccounts/dialog/PaymentAccountsDialogFragmentDirections$Companion; or its super classes (declaration of 'de.mypck.payments.ui.paymentAccounts.dialog.PaymentAccountsDialogFragmentDirections$Companion' appears in /data/app/~~UQv870BGZwE5Mh0gNeM8VQ==/de.mypck.myapp-JaRbZHxoM0f-CTNkO2Fsmw==/base.apk!classes4.dex)
        at de.mypck.payments.ui.paymentAccounts.dialog.PaymentAccountsDialogFragment$setupViewModelObservers$1.onChanged(PaymentAccountsDialogFragment.kt:66)
        at de.mypck.payments.ui.paymentAccounts.dialog.PaymentAccountsDialogFragment$setupViewModelObservers$1.onChanged(PaymentAccountsDialogFragment.kt:26)
        at de.mypck.core.mvvm.SingleLiveEvent$observe$1.onChanged(SingleLiveEvent.kt:26)
        at androidx.lifecycle.LiveData.considerNotify(LiveData.java:133)
        at androidx.lifecycle.LiveData.dispatchingValue(LiveData.java:151)
        at androidx.lifecycle.LiveData.setValue(LiveData.java:309)
        at androidx.lifecycle.MutableLiveData.setValue(MutableLiveData.java:50)
        at de.mypck.core.mvvm.SingleLiveEvent.setValue(SingleLiveEvent.kt:35)
        at de.mypck.payments.ui.paymentAccounts.PaymentAccountsViewModel.navTransactions(PaymentAccountsViewModel.kt:24)
        at de.mypck.payments.ui.paymentAccounts.adapter.PaymentAccountItemAdapter$buildView$1.onClick(PaymentAccountItemAdapter.kt:88)
        at android.view.View.performClick(View.java:8160)
        at android.view.View.performClickInternal(View.java:8137)
        at android.view.View.access$3700(View.java:888)
        at android.view.View$PerformClick.run(View.java:30236)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:246)
        at android.app.ActivityThread.main(ActivityThread.java:8506)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
walli
  • 53
  • 5
  • add full navigation file to be able to help , apparently there are no action with that id . – Mustafa Ibrahim Mar 01 '21 at 15:22
  • I edited the post accordingly – walli Mar 02 '21 at 10:09
  • I further tried to resolve this issue and found out that the IDs for the destinations/actions are not generated. Therefore navigation by ID is also not possible. This is probably also the issue with the generated safeargs action class... – walli Mar 03 '21 at 09:48

0 Answers0