2

so previously I had crash with error:

You must call setGraph() before calling getGraph()

then after reading the solution frem here. it is said that I have to use these lines on my gradle

implementation "androidx.navigation:navigation-fragment:2.3.0-alpha02"
implementation "androidx.navigation:navigation-ui:2.3.0-alpha02"

and the error is dissapear. but now I no longer can find setupWithNavController method. usually I use this line

toolbar.setupWithNavController(navController,appBarConfiguration)

but I no longer find that method. what should I do ?

enter image description here

sarah
  • 3,819
  • 4
  • 38
  • 80
  • Does this answer your question? [Why Android Studio shows setupWithNavController not exists?](https://stackoverflow.com/questions/52768334/why-android-studio-shows-setupwithnavcontroller-not-exists) – murgupluoglu Mar 09 '20 at 10:06
  • @murgupluoglu I have tried the solution from there but it just doesn't work, I have tried to restart android studio, clear and rebuild, but I still can't find the method – sarah Mar 09 '20 at 10:13
  • 2
    That comes from `-ktx` dependencies and you are not adding the `-ktx` dependencies. – EpicPandaForce Mar 09 '20 at 10:57

1 Answers1

2

To use any of the NavigationUI Kotlin extension functions, you must use the -ktx version of the dependencies.

implementation "androidx.navigation:navigation-fragment-ktx:2.3.0-alpha02"
implementation "androidx.navigation:navigation-ui-ktx:2.3.0-alpha02"
ianhanniballake
  • 191,609
  • 30
  • 470
  • 443