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

Compose Compiler版本兼容问题求助:1.3.2要求Kotlin 1.7.20但当前为1.9.23

e: 此版本(1.3.2)的Compose Compiler要求使用Kotlin版本1.7.20,但您当前使用的是Kotlin版本1.9.23,该版本兼容性未知。

这个错误逻辑很明确,别的项目里只要版本匹配就能正常运行,但这个项目不管怎么操作,错误一直存在。项目里根本没引用1.3.2版本的Compose Compiler,只有主App模块在用Compose,试过清理构建缓存、重启IDE清缓存,问题还是没解决。

这是个多模块项目,所有Gradle脚本用的都是同一个Kotlin版本,各模块配置如下:

build.gradle (项目根目录)

buildscript {
    ext {
        kotlin_version = '1.9.23'
        compose_version = '1.6.5'
        kotlinCompilerExtensionVersion = '1.5.11'
        ...
    }

    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        ...
    }
}

build.gradle (app模块)

apply plugin: 'kotlin-android'

android {
    ...

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }

    kotlinOptions {
        jvmTarget = "17"
    }

    composeOptions {
        kotlinCompilerExtensionVersion kotlinCompilerExtensionVersion
    }

    buildFeatures {
        compose true
    }
}
dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

    // Compose
    implementation "androidx.compose.ui:ui:$compose_version"
    implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
    debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"

    // somewhere on a google doc it noted to NOT include this. Here just in case.
    // implementation "androidx.compose.material:material:$compose_version"
}

build.gradle (module a)

plugins {
    id 'com.android.library'
}
apply plugin: 'kotlin-android'

android {
    ...

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }

    kotlinOptions {
        jvmTarget = "17"
    }
}
dependencies {
    implementation 'androidx.core:core-ktx:1.12.0'
}

build.gradle (module b)

plugins {
    id 'com.android.library'
}
apply plugin: 'kotlin-android'

android {
    ...

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }

    kotlinOptions {
        jvmTarget = "17"
    }
}
dependencies {
    implementation 'androidx.core:core-ktx:1.12.0'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.25 23:42:32