Android : `androidx.navigation.NavArgs` not found

Prashant Jajal picture Prashant Jajal · Mar 2, 2019 · Viewed 7.9k times · Source

I fetch this below code from From Codelab for navigation controller

But getting this below error: spend already more the 3 hours but not any success. Here is my error

Please help me to solve this error.

Answer

Amin Keshavarzian picture Amin Keshavarzian · Oct 1, 2019

Change this

  implementation 'android.arch.navigation:navigation-fragment-ktx:2.2.0-alpha01'
  implementation 'android.arch.navigation:navigation-ui-ktx:2.2.0-alpha01'

to this:

  implementation 'androidx.navigation:navigation-fragment-ktx:2.2.0-alpha01'
  implementation 'androidx.navigation:navigation-ui-ktx:2.2.0-alpha01'

Notice that android.arch.navigation is replaced with androidx.navigation

also, make sure to apply this plugin on top of build.gradle:

apply plugin: "androidx.navigation.safeargs.kotlin"

and this to the dependencies to the project level build.gradle:

 classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.1.0-rc01"