google-developer-training / android-basics-kotlin-cupcake-app

Apache License 2.0
103 stars 163 forks source link

Android Basics: Shared ViewModel #62

Closed gYellowLive closed 10 months ago

gYellowLive commented 2 years ago

URL of codelab https://developer.android.com/codelabs/basic-android-kotlin-training-shared-viewmodel?authuser=2&continue=https%3A%2F%2Fdeveloper.android.com%2Fcourses%2Fpathways%2Fandroid-basics-kotlin-unit-3-pathway-4%3Fauthuser%3D2%23codelab-https%3A%2F%2Fdeveloper.android.com%2Fcodelabs%2Fbasic-android-kotlin-training-shared-viewmodel#2

In which task and step of the codelab can this issue be found? step 3

Describe the problem the import for "findNavController().navigate(R.id.action_flavorFragment_to_pickupFragment)" should be "import androidx.fragment.app.Fragment" instead of what's in the codelab description "Import androidx.navigation.fragment.findNavController" or what's shown in the codelab image.

Steps to reproduce?

  1. Go to...
  2. Click on...
  3. See error...

(follow step 3 and it won't compile)

Versions Android Studio version: 2021.1.1 patch 2 API version of the emulator: Pixel 4 XL API 32

Additional information Include screenshots if they would be useful in clarifying the problem.

gYellowLive commented 2 years ago

I did it in this live stream: https://www.youtube.com/watch?v=L8jOcYL_Rb4

nithin14 commented 2 years ago

Yes, the import shown in the screenshot is not accurate, as you are not passing in any arguments while invoking findNavController() function. The correct import is [import androidx.navigation.fragment.findNavController].