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

Compose Compiler与Kotlin版本不兼容致编译调试失败求助

解决Compose Compiler 1.1.1与Kotlin版本不兼容问题
  • 检查项目根目录build.gradle的Kotlin版本配置
    确保buildscript块里的kotlin_version明确设置为1.6.10,同时Kotlin Gradle插件的版本也与之匹配:

    buildscript {
        ext {
            kotlin_version = "1.6.10"
            compose_compiler_version = "1.1.1"
        }
        dependencies {
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        }
    }
    
  • 确认app模块build.gradle(:app)的Kotlin插件版本
    顶部的Kotlin插件引用必须和根目录配置的版本保持一致:
    如果是声明式引用:

    plugins {
        id 'com.android.application'
        id 'org.jetbrains.kotlin.android' version "$kotlin_version" apply false
    }
    

    如果是直接应用插件,会默认继承根目录的版本,此时要确保根目录的kotlin_version配置正确:

    plugins {
        id 'com.android.application'
        id 'org.jetbrains.kotlin.android'
    }
    
  • 排查是否有依赖强制引入高版本Kotlin
    执行./gradlew dependencies命令,搜索kotlin-stdlib、kotlin-reflect等核心依赖,查看是否有1.7.10版本被第三方依赖引入。如果存在,可通过强制指定版本来覆盖:

    configurations.all {
        resolutionStrategy {
            force "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.10"
            force "org.jetbrains.kotlin:kotlin-reflect:1.6.10"
        }
    }
    
  • 清理Gradle缓存并重新同步
    执行./gradlew clean build --refresh-dependencies命令,清除旧的缓存文件,让Gradle重新读取配置并下载对应版本的依赖包。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.22 16:57:15