未解决的参考:lifecycle_version [developer.android.com/codelabs]

问题描述 投票:0回答:1

代码在这里:

起始代码网址:

https://github.com/google-developer-training/basic-android-kotlin-compose-training-dessert-clicker

带有起始代码的分支名称:main


Codelab 中的说明:https://developer.android.com/codelabs/basic-android-kotlin-compose-test-viewmodel?continue=https%3A%2F%2Fdeveloper.android.com%2Fcourses%2Fpathways%2Fandroid- basics-compose-unit-4-pathway-1%23codelab-https%3A%2F%2Fdeveloper.android.com%2Fcodelabs%2Fbasic-android-kotlin-compose-test-viewmodel#3


    Add the following variable to your project build.gradle file:
buildscript {
   ext {
       ...
       lifecycle_version = '2.5.1'
   }
}

但是,将其添加到

build.gradle.kts
(项目)会导致错误:

Unresolved reference: lifecycle_version

此外,

buildscript {
    ext {

不存在,我必须手动定义它并用

lifecycle_version
填充它,而在 Codelab 中它的示例就好像它已经存在一样。

有人完成了 Codelab 并且知道如何继续进行吗?我有点被困住了。

android
1个回答
0
投票

最后我补充了

    implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.5.1")

build.gradle.kts(应用程序)。

© www.soinside.com 2019 - 2024. All rights reserved.