google-developer-training/android-kotlin-fundamentals-apps

Android Kotlin Fundamentals codelab:

gidiav opened this issue · 1 comments

Name of the Codelab or Codelab URL
Android Kotlin Fundamentals: 5.1 ViewModel

Describe the problem
Compiler errors

  1. Error described here - can be resolved by using lifecycle library 2.4.1 instead of the latest one

  2. Then, this error: Class 'ScoreViewModelFactory' is not abstract and does not implement abstract member public abstract fun create(modelClass: Class): T defined in androidx.lifecycle.ViewModelProvider.Factory

After looking closely I saw that the codelab has "fun <T : ViewModel?>" while the error says "fun ", i.e., without teh question mark. After removing the question mark, it compiles.

In which lesson and step of the codelab can this issue be found?
Part 8 (Use a ViewModelFactory), step 6

How to reproduce?
Follow all the steps in the codelab and compile

Versions

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

Additional information
Add any other context about the problem here.

codelab: android-kotlin-fundamentals

Hello! Thank you for your feedback. This codelab is out of date and no longer maintained. Instead, please refer to the Android Basics with Compose course for the latest recommended practices. If you are looking for content on Views, you can check out the Android Basics in Kotlin course.