google-developer-training / basic-android-kotlin-compose-training-lunch-tray

Apache License 2.0
41 stars 49 forks source link

Add a ViewModel to Dessert Clicker: Android Basics in Compose #38

Open dylantrepos opened 6 months ago

dylantrepos commented 6 months ago

With my current version of Kotlin, I don't have build.gradle file but build.gradle.kts so in order to add thoses imports, i had to do :

1. Add the following variable to your project build.gradle file:

buildscript { extra.apply { set("lifecycle_version", "2.5.1") } }

2. Add the following dependency to the app/build.gradle file:

dependencies { val lifecycle_version = rootProject.extra["lifecycle_version"] ... implementation("androidx.lifecycle:lifecycle-viewmodel-compose:$lifecycle_version") ... }


Not sure if it's the best way to do because I'm a newbie in Android, but at least it works for me, so it may works for others. Thank you !