Search code examples
javaandroidandroid-architecture-navigation

How to fix (error: cannot find symbol class ActionOnlyNavDirections) with navigation architecture in Android studio


I'm using navigation architecture component in Android studio. I used it with the bottom app bar and it worked perfectly but whenever I try to add an action I get this error while launching the app (error: cannot find symbol class "ActionOnlyNavDirections")

<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/nav_graph"
app:startDestination="@id/Around">

<fragment
    android:id="@+id/Around"
    android:name="com.Czynt.kazdoura.AroundFragment"
    android:label="fragment_around"
    tools:layout="@layout/fragment_around">
    <action
        android:id="@+id/action_Around_to_listView"
        app:destination="@id/listView" />

</fragment>
<fragment
    android:id="@+id/listView"
    android:name="com.Czynt.kazdoura.ListView"
    android:label="fragment_list_view"
    tools:layout="@layout/fragment_list_view" />
   </navigation>

 public class AroundFragment extends Fragment{
    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    TabItem listTab = getActivity().findViewById(R.id.listTab);
    listTab.setOnClickListener(Navigation.createNavigateOnClickListener(R.id.action_Around_to_listView,null));

Solution

  • I updated android studio and all the dependencies in my app and it worked