9

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"
Rahul Bhavani
  • 311
  • 2
  • 10

6 Answers6

7

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"
Jin Lee
  • 3,194
  • 12
  • 46
  • 86
ibrahim ali
  • 86
  • 1
  • 2
1

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)

marcusdrl
  • 11
  • 1
0

I also had the exact same problem, I was using older library version(1.0.0-alpha05)

But as soon as I switched to

implementation "android.arch.navigation:navigation-fragment-ktx:1.0.0"
implementation "android.arch.navigation:navigation-ui-ktx:1.0.0"

Other fragments started showing up!

Shivam Sompura
  • 125
  • 1
  • 10
0

I am facing this issue even with version 2.2.1. I have solved this by adding the fragment in the XML code. Then I am able to add actions from the visual editor.

Example:

<fragment
    android:id="@+id/test"
    android:name="com.example.test.ui.test.TestFragment"
    android:label="Test Label"
    tools:layout="@layout/fragment_test"/>
Patriotic
  • 2,103
  • 4
  • 26
  • 36
0

Sometimes Fragments don't show up in the graph because classes haven't been made for them. After calling onViewCreate within a class, while returning correct inflater they show up in the graph.

Dharman
  • 30,962
  • 25
  • 85
  • 135
zulu_papa
  • 415
  • 6
  • 12
0

Just I built and Run the project once. Then Fragments appeared as destinations in the Fragments List in NavGraph.

harsh
  • 577
  • 7
  • 10