Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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"
like image 714
Rahul Bhavani Avatar asked Mar 12 '19 04:03

Rahul Bhavani


People also ask

How do you enable your project to use navigation components?

The navigation editor is a standard part of Android Studio 3.3 and higher. If you're using Android Studio 3.2, navigation is an experimental feature and you'll need to enable it: Click File > Settings (Android Studio > Preferences on Mac) Select the Experimental category in the left pane.


2 Answers

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"
like image 182
ibrahim ali Avatar answered Oct 18 '22 02:10

ibrahim ali


I had the same problem and i solved it by simply checking the superior build-gradle for the kotlin version, it may be the case if you recently updated your kotlin plugin but didnt update your code.

So in android studio in project navigation bar(ANDROID): Gradle Scripts -> build.gradle(project) -> look for buildscript - ext and update "kotlin_version" for your kotlin plugin version (this can be checked in tools -> kotlin -> Configure kotlin plugin updates)

like image 30
marcusdrl Avatar answered Oct 18 '22 04:10

marcusdrl