I have multiple nav graphs in my projects each has multiple actions defined.
Lately, I am getting this error while Building the app preventing me from generating APK
Unresolved reference: action...
This error appears in some actions only (4 exactly), not all of them. And I can't figure out why.
findNavController().navigate(MyAppClassDirections.actionTasksToFooClassDetails(
item.requestNumber,
item.id.toString(),
ActionCode.Inbox //Enum
))
And this is the action declaration in NavGraph
<action
android:id="@+id/action_tasks_to_foo_class_details"
app:destination="@id/my_other_dest"
app:enterAnim="@anim/slide_in_left"
app:exitAnim="@anim/slide_out_right"
app:popEnterAnim="@anim/pop_enter"
app:popExitAnim="@anim/pop_exit">
<argument
android:name="requestNumber"
app:argType="string" />
<argument
android:name="id"
app:argType="string" />
<argument
android:name="actionCode"
app:argType="com.myapp.data.ActionCode" />
</action>
Note: Same action like this is declared several times in the graphs and are working fine. Some how this specific declaration is causing the issue.
My conclusion so far: I don't think it is a code error. However, it is most likely a cache issue or something wrong with the navigation library.
I am using navigation:2.5.3
What I have done:
- Invalidate cache and restart Android Studio (Several Times).
- Clean/Rebuild project (Several Times).
- Removed the class and added it again.
- Renamed the action's id.
Nothing worked... :(
Any idea how to fix this??
It looks like you have to add some default value to enum that match with provided one as mentioned in documentation
So as per your code you can do like this
Please check this link https://developer.android.com/guide/navigation/navigation-pass-data#supported_argument_types