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

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

Open
tusharvermaIndia opened this issue Aug 7, 2024 · 2 comments
Open

Comments

@tusharvermaIndia
Copy link

in unit 4 , pathway 2, chapter "Practice: add a view model to dessert clicker", subsection 3 (Set up dependencies), it has been instructed to add following variable to the build.gradle file ->
buildscript {
ext {
...
lifecycle_version = '2.5.1'
}
}

but it should have been like this ->

buildscript {
ext[

        "lifecycle_version"] = "2.5.1"

}
@Akronix
Copy link

Akronix commented Aug 8, 2024

I fixed it by following this stack overflow answer.

So, I declare the variables in the project gradle file:

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

And then I referred to that variable in the build.gradle.kts of the app module and assign it to the dependencies:

val lifecycle_version = rootProject.extra.get("lifecycle_version") as String 

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

@tusharvermaIndia
Copy link
Author

nice. i did something similar
buildscript {
extra["lifecycle_version"] = "2.6.1"
}

and then
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:$(lifecycle_version)")

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