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

React Native项目构建失败:expo-modules-core:compileDebugKotlin报错

解决Expo 51 + React Native 0.73.5构建时Kotlin编译错误

问题详情

构建项目时触发如下编译失败错误:

Task :expo-modules-core:compileDebugKotlin FAILED
e: file:///C:/Users/dell/Desktop/FDR/FR_APP/node_modules/expo-modules-core/android/src/main/java/expo/modules/kotlin/defaultmodules/CoreModule.kt:88:21 Unresolved reference: reload

当前环境配置:

  • 项目级build.gradle参数:
buildToolsVersion = "34.0.0"
minSdkVersion = 21
compileSdkVersion = 34
targetSdkVersion = 34
ndkVersion = "25.1.8937393"
kotlinVersion = "1.9.0"
  • 核心依赖版本:
Expo - 51.0.31
React Native - 0.73.5

解决方案

1. 升级Kotlin版本

Expo 51对Kotlin版本有兼容要求,当前使用的1.9.0存在适配问题,修改项目根目录build.gradle(项目级)中的kotlinVersion:

kotlinVersion = "1.9.20"

2. 清理依赖与缓存

  • 删除项目根目录的node_modules、package-lock.json(或yarn.lock)文件
  • 重新安装依赖:
    npm install
    # 或 yarn install
    
  • 清理Android Gradle缓存:
    cd android
    gradlew clean  # Windows系统执行
    # ./gradlew clean  # macOS/Linux系统执行
    

3. 锁定expo-modules-core兼容版本

在package.json中添加resolutions字段,指定与Expo 51匹配的expo-modules-core版本:

"resolutions": {
  "expo-modules-core": "1.12.17"
}

添加完成后重新执行依赖安装命令。

4. 重新构建项目

执行以下命令重新构建Android项目:

npx react-native run-android

内容的提问来源于stack exchange,提问作者Johão Pedro

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.19 05:24:54