This repository was archived by the owner on Jul 24, 2023. It is now read-only.

Description
Name of the Codelab or Codelab URL
Android Kotlin Fundamentals: 5.1 ViewModel
https://codelabs.developers.google.com/codelabs/kotlin-android-training-view-model/index.html?index=..%2F..android-kotlin-fundamentals#7
Describe the problem
wrong variable
In which lesson and step of the codelab can this issue be found?
- 5.1 ViewModel
-- 8. Task: Use a ViewModelFactory
--- Step 8.) "In ScoreFragment, inside OnCreateView(), after [..]
viewModelFactory = ScoreViewModelFactory(ScoreFragmentArgs.fromBundle(arguments!!).score)"
How to reproduce and solve the problem?
arguments!! can't be resolved.
Replace arguments!! with requireArguments()
Result:
viewModelFactory = ScoreViewModelFactory(ScoreFragmentArgs.fromBundle(requireArguments()).score)
Versions
- What version of Android Studio are you using? --> 4.1
- What API level are you targeting? --> 30