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

Kotlin版本不兼容咨询:元数据二进制版本1.8.0与1.6.0不匹配

Kotlin版本不兼容(元数据1.8.0 vs 预期1.6.0)解决方案

1. 统一项目Kotlin版本

项目中Kotlin插件版本与依赖的stdlib版本必须保持一致,可选择升级到1.8.0或降级到1.6.0:

  • 根目录build.gradle(Groovy格式):
    buildscript {
        ext.kotlin_version = "1.8.0" // 替换为目标版本,如1.6.0或1.8.0
        dependencies {
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        }
    }
    
  • 模块目录build.gradle(Groovy格式):
    dependencies {
        implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
        implementation "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlin_version"
    }
    
  • 若使用KTS格式(build.gradle.kts):
    plugins {
        kotlin("jvm") version "1.8.0" // 统一版本号
    }
    
    dependencies {
        implementation(kotlin("stdlib"))
        implementation(kotlin("stdlib-common"))
    }
    

2. 清理Gradle缓存

缓存中残留的旧版本依赖会导致冲突,执行以下操作:

  • 执行Gradle命令强制刷新依赖:
    ./gradlew clean build --refresh-dependencies
    
  • 或手动删除报错指向的缓存目录:C:/Users/LENOVO/.gradle/caches/transforms-2/files-2.1/33fa47401fa8ac91195ccfa117fbdede/,也可直接删除整个.gradle/caches文件夹。

3. 排查第三方依赖冲突

部分第三方库可能内置了不兼容的Kotlin stdlib:

  • 执行命令查看完整依赖树:
    ./gradlew dependencies
    
  • 找到依赖树中使用kotlin-stdlib-common:1.8.0的库,若无法升级项目Kotlin版本,可排除该库的内置stdlib依赖,手动添加兼容版本:
    implementation("com.example:target-library:1.0.0") {
        exclude group: "org.jetbrains.kotlin", module: "kotlin-stdlib-common"
    }
    

内容的提问来源于stack exchange,提问作者Parmit Singh Malik

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.03 17:45:51