Skip to content
This repository has been archived by the owner on Jul 24, 2023. It is now read-only.

Android Kotlin Fundamentals codelab: #70

Closed
AhmedAshour opened this issue Mar 11, 2020 · 2 comments
Closed

Android Kotlin Fundamentals codelab: #70

AhmedAshour opened this issue Mar 11, 2020 · 2 comments
Labels
duplicate This issue or pull request already exists

Comments

@AhmedAshour
Copy link

AhmedAshour commented Mar 11, 2020

Describe the problem
According to the documentation:

The APIs in lifecycle-extensions have been deprecated

So in the ViewModel and ViewModelFactory codelab (5. Task: Create the GameViewModel), the dependency of ViewModel should be changed from:

//ViewModel
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'

to:

// ViewModel
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0"

Also, the ViewModelProviders.of() is deprecated so instead of:

Log.i("GameFragment", "Called ViewModelProviders.of")
viewModel = ViewModelProviders.of(this).get(GameViewModel::class.java)

should be changed to:

Log.i("GameFragment", "Called ViewModelProviders.of")
viewModel = ViewModelProvider(this).get(GameViewModel::class.java)

In which lesson and step of the codelab can this issue be found?
Lesson number: 05.1
Step number: 5

How to reproduce?
Open the lesson

Versions

  1. What version of Android Studio are you using? Not relevant
  2. What API level are you targeting? Not relevant

Additional information
Add any other context about the problem here.

codelab: android-kotlin-fundamentals

@Patrick-Wallin
Copy link

Perfect! It works! If you could not compile it, do not forget to remove import for ViewModelProviders.

@flplatet
Copy link

Duplicate of #29

@GeneAndGoogle GeneAndGoogle added the duplicate This issue or pull request already exists label May 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

4 participants