gpt4 book ai didi

android - Unresolved reference : ext when convert gradle to gradle. kts

转载 作者:行者123 更新时间:2023-12-04 23:58:57 30 4
gpt4 key购买 nike

默认情况下,当我从 Android Studio 创建一个撰写应用程序时,它会给我 ext在我的根项目中如下 build.gradle .

buildscript {
ext {
compose_version = '1.0.0'
}
repositories {
google()
mavenCentral()
}
}
当我将其更改为 build.gradle.kts ,它会提示
Unresolved reference: ext
Unresolved reference: compose_version
Too many characters in a character literal ''1.0.0''
我该如何解决这个问题?

最佳答案

我用

buildscript {
extra.apply{
set("compose_version", "1.0.0")
}
repositories {
google()
mavenCentral()
}
从其他 gradle 访问它文件,我需要明确设置为一个变量
val composeVersion = rootProject.extra.get("compose_version") as String
然后我可以像使用它一样
composeOptions {
kotlinCompilerExtensionVersion = composeVersion
}
dependencies {
implementation ("androidx.compose.ui:ui:$composeVersion")
}

关于android - Unresolved reference : ext when convert gradle to gradle. kts,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69323109/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com