Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Destination with arguments or actions must have 'name' or 'id' attributes

I created a global action with the Android Navigation Component and I'm getting the following error when compiling the code

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

<fragment
    android:id="@+id/homeEnumerationFragment"
    android:name="org.southasia.ghru.ui.homeenumeration.HomeEnumerationFragment"
    android:label="HomeEnumerationFragment"
    tools:layout="@layout/home_enumeration_fragment"></fragment>


<fragment
    android:id="@+id/stationFragments"
    android:name="org.southasia.ghru.ui.station.StationFragment"
    android:label="StationFragment"
    tools:layout="@layout/station_fragment"/>

<fragment
    android:id="@+id/devicesFragment"
    android:name="org.southasia.ghru.ui.devices.DevicesFragment"
    android:label="DevicesFragment"
    tools:layout="@layout/devices_fragment"/>
<action android:id="@+id/action_global_stationFragments3" app:destination="@+id/stationFragments"/>

The error:

Error: Destination with arguments or actions must have 'name' or 'id' attributes.
like image 252
Shanuka Avatar asked Jun 12 '18 08:06

Shanuka


1 Answers

To use global action you need to have an id for your navigation graph (currently it is not generated automatically). Just add 'id' attribute to your navigation element, like this:

<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"
   app:startDestination="@id/homeEnumerationFragment"
   android:id="@+id/main">
like image 66
Alex Avatar answered Sep 28 '22 01:09

Alex