Search code examples
androidandroid-architecture-componentsandroid-architecture-navigation

Failed to resolve: fragment after adding navigation


I got this error when I try to add dependencies for Navigation

Failed to resolve: fragment

I have add those lines:

implementation "android.arch.navigation:navigation-fragment-ktx:$navigationVersion"
implementation "android.arch.navigation:navigation-ui-ktx:$navigationVersion"

In project gradle this is what I add:

ext{
    navigationVersion = '1.0.0-alpha09'
}
repositories {
    google()
    jcenter()
}

I tried to invalidate cache & restart and It didn't work.

Side note I have migrated to androidx with no problem but after I tried to add the Navigation library, this error appears


Solution

  • In your code, set navigationVersion = '2.0.0' is OK