google-developer-training / basic-android-kotlin-compose-training-dessert-clicker

Apache License 2.0
53 stars 142 forks source link

buildscript ext does not work #21

Open plugie opened 1 year ago

plugie commented 1 year ago

URL of codelab https://github.com/google-developer-training/basic-android-kotlin-compose-training-dessert-clicker/tree/main

In which task and step of the codelab can this issue be found? Set up dependencies

Describe the problem buildscript ext does not work

Steps to reproduce?

  1. Add in build.gradle.kts buildscript { ext { lifecycle_version = '2.5.1' } }
  2. See error... Unresolved reference: ext

Versions Android Studio version: Giraffe 2022.3.1 Patch 2 API version of the emulator: 32

Additional information Include screenshots if they would be useful in clarifying the problem.

patrykharanczyk commented 1 year ago

I fixed it this way for myself:

In build.gradle.kts instead of that sample code define it this way: buildscript { extra.apply { set("lifecycle_version", "2.5.1") } }

Then in app/build.gradle add two things Before dependiencies block add: val lifecycle_version = rootProject.extra["lifecycle_version"] In dependencies add: implementation("androidx.lifecycle:lifecycle-viewmodel-compose:$lifecycle_version")

Hope this helps you.