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 #17

Open AsquaredWsquared opened 1 year ago

AsquaredWsquared commented 1 year ago

The two code snippets below from the code lab give me errors as others have mentioned:

buildscript {
   ext {
       lifecycle_version = '2.5.1'
   }
}

and

dependencies { implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$lifecycle_version" }

I got this working in Android Studio Giraffe | 2022.3.1 Patch 2 with the following (I'm a total newb to Android dev and Gradle so this is probably not the correct way to do this)

The code for the project build.gradle.kts :

val lifecycle_version by rootProject.extra { "2.5.1" }

and the code for the app build.gradle.kts :

implementation("androidx.lifecycle:lifecycle-viewmodel-compose:${rootProject.extra.get("lifecycle_version")}")

Eetu123E commented 1 year ago

Thanks! I was having the same problem

otakutyrant commented 6 months ago

OMG, the official tutorial still does not fix this issue after half one year.