androidandroid-architecture-componentsandroid-architecture-navigationandroid-studio-3.2

Navigation Preview unavailable in Android Studio 3.2 Preview


I am interested to try the Navigation graph showed in the Android Studio. But I got the preview unavailable after I import the google sample

I used the Android Studio 3.2 Preview Canary 16

enter image description here

<navigation xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    app:startDestination="@+id/launcher_home">

    <fragment
        android:id="@+id/launcher_home"
        android:name="com.android.samples.arch.componentsbasicsample.StartFragment"
        android:label="Home">

        <action
            android:id="@+id/end_action"
            app:destination="@id/end_dest" />

    </fragment>

    <fragment
        android:id="@+id/end_dest"
        android:name="com.android.samples.arch.componentsbasicsample.EndFragment"
        android:label="End"
        >

    </fragment>
</navigation>

Update on 10/6/2018:

Even I rebuild the project it doesn't work. But if added new screen, it showed the new one in preview mode

enter image description here


Solution

  • You should click on "text" tab in navigation editor (xml file of the navigation graph), and add:

    tools:layout="@layout/layout_name"
    

    inside destination element.

    Should be something like this:

    <fragment
        android:id="@+id/someFragment"
        android:name="com.freesoulapps.navigationtest.fragments.SomeFragment"
        android:label="Some Fragment"
        tools:layout="@layout/layout_name">
    </fragment>