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"
6
  • try rebuild the project. Commented Mar 12, 2019 at 5:06
  • Sounds like you should file an issue against the Navigation Editor with a project that reproduces your issue. Commented Mar 12, 2019 at 5:06
  • Can you share your gradle with the dependency list? Commented Mar 12, 2019 at 5:28
  • @MDNaseemAshraf edited the question. Commented Mar 12, 2019 at 14:47
  • I think I am using wrong dependency Commented Mar 12, 2019 at 14:54

6 Answers 6

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"
Sign up to request clarification or add additional context in comments.

1 Comment

adding the navigation-fragment dependency did the trick for me!
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)

Comments

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!

Comments

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"/>

Comments

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.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.