下面是一个小的 (build.gradle.kts) 脚本,它在第 9 行(类路径行)给出错误:无法在额外的属性扩展上获取属性“kotlinVersion”,因为它不存在
buildscript {
extra["kotlinVersion"] = "1.2.70"
repositories {
jcenter()
}
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${extra["kotlinVersion"]}")
}
}
我不明白为什么会出现这个错误。
最佳答案
这对我有用:
buildscript {
extra["kotlin_version"] = "1.3.61"
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:3.5.3")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${extra["kotlin_version"]}")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
关于kotlin - 使用额外属性的 build.gradle.kts 脚本中的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60205104/