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

Expo裸工作流中Compose Compiler与Kotlin版本兼容问题

解决方案:Compose Compiler版本不兼容问题(React Native + Expo裸工作流)

核心问题分析

你手动指定了Kotlin 1.9.25和Compose 1.5.15,但构建仍提示使用的是Compose Compiler 1.5.14,说明某个第三方依赖(可能是React Native或Expo的预配置依赖)强制引入了旧版Compiler,覆盖了你手动设置的版本。


具体解决步骤

1. 定位旧版依赖来源

执行以下命令查看项目依赖树,找到引入compose-compiler:1.5.14的依赖:

./gradlew app:dependencies | grep "compose-compiler"

(如果你的模块不是app,替换成对应模块名称)

2. 强制统一Compose Compiler版本

在项目根目录的build.gradle文件中,添加版本强制策略,确保所有依赖都使用指定的1.5.15版本:

allprojects {
    repositories {
        // 保留你原有的仓库配置(比如google(), mavenCentral()等)
    }

    configurations.all {
        resolutionStrategy.force "androidx.compose.compiler:compiler:1.5.15"
    }
}

3. 结合Expo插件强制版本(裸工作流专属)

因为使用Expo裸工作流,Expo的预配置可能覆盖你的Gradle设置,建议通过expo-build-properties插件统一管理版本:

  • 先安装插件:
npx expo install expo-build-properties
  • 在app.json或app.config.js中添加配置:
{
  "expo": {
    "plugins": [
      [
        "expo-build-properties",
        {
          "android": {
            "kotlinVersion": "1.9.25",
            "composeCompilerVersion": "1.5.15"
          }
        }
      ]
    ]
  }
}
  • 重新生成裸工作流配置:
npx expo prebuild --clean

4. 彻底清理缓存后重新构建

仅执行./gradlew clean可能不够,需要清理Gradle全局缓存:

  • Mac/Linux:
rm -rf ~/.gradle/caches
./gradlew clean
./gradlew assembleRelease
  • Windows:
    删除C:\Users\<你的用户名>\.gradle\caches目录,然后执行:
gradlew clean
gradlew assembleRelease

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.14 11:28:18