You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Android/Gradle项目的buildSrc中访问org.jetbrains.kotlin.gradle.dsl.JvmTarget?

解决方法

你需要在buildSrc的构建脚本中添加Kotlin Gradle插件的依赖,就能访问org.jetbrains.kotlin.gradle.dsl.JvmTarget这类Kotlin Gradle DSL相关类型了。

修改后的build.gradle.kts配置如下:

plugins {
    `kotlin-dsl`
}

repositories {
    mavenCentral()
}

dependencies {
    // 替换成你项目实际使用的Kotlin版本号,建议和主项目版本保持一致
    implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.20")
}

注意:务必保证这里的Kotlin版本号和你项目主模块中使用的Kotlin版本匹配,避免出现版本冲突问题。

内容的提问来源于stack exchange,提问作者JJD

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.30 15:12:33