androidandroidxandroid-jetpacknavigation-architecture

Android Navigation Component: Fragments are not visible in drop down list when adding destination from nav_graph.xml


When I am trying to add a destination when clicking enter image description here "New destination" button, from the dropdown list I am not able to see any fragments which are already there in my project.

I also face this issue when I am trying to add a blank fragment by clicking "Create a blank destination" option from the drop down.

I tried restarting the IDE, and this Android Navigation Component Not Displaying Fragment but it doesn't resolve my issue.

Navigation dependency: implementation "androidx.navigation:navigation-fragment:1.0.0-rc02"

My project is already migrated to AndroidX.

Am I missing something? Any help would be appreciated.

Gradle dependency:

def nav_version = "1.0.0-rc02"

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0-alpha02'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.2-alpha02'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0-alpha02'
implementation 'androidx.cardview:cardview:1.0.0'

implementation "android.arch.navigation:navigation-fragment:$nav_version"

Solution

  • I had the same problem. Just use these dependencies.

    //Android Navigation Architecture
        implementation "androidx.navigation:navigation-fragment-ktx:2.1.0-alpha05"
        implementation "androidx.navigation:navigation-ui-ktx:2.1.0-alpha05"