Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buildscript ext does not work #21

Open
plugie opened this issue Oct 27, 2023 · 1 comment
Open

buildscript ext does not work #21

plugie opened this issue Oct 27, 2023 · 1 comment

Comments

@plugie
Copy link

plugie commented Oct 27, 2023

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
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants