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

升级React Native 0.73+Expo 50.0.3遇fbjni依赖冲突求助

React Native 0.73 + Expo 50.0.3 依赖冲突:com.facebook.fbjni版本不兼容问题

问题场景

升级React Native到0.73版本并搭配Expo 50.0.3时,出现以下依赖解析错误:

Could not determine the dependencies of task ':expo-modules-core:compileDebugJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':expo-modules-core:debugCompileClasspath'.
   > Could not resolve com.facebook.fbjni:fbjni:0.5.1.
     Required by:
         project :expo-modules-core
      > Cannot find a version of 'com.facebook.fbjni:fbjni' that satisfies the version constraints:
           Dependency path 'host.exp.exponent:expo-modules-core:1.11.8' ---> 'com.facebook.fbjni:fbjni:0.5.1'
           Constraint path 'host.exp.exponent:expo-modules-core:1.11.8' ---> 'com.facebook.fbjni:fbjni:{strictly 0.3.0}' because of the following reason: debugRuntimeClasspath uses version 0.3.0
           Dependency path 'host.exp.exponent:expo-modules-core:1.11.8' ---> 'com.facebook.react:react-android:0.72.6' (debugVariantDefaultApiPublication) ---> 'com.facebook.fbjni:fbjni:0.3.0'

   > Could not resolve com.facebook.fbjni:fbjni:{strictly 0.3.0}.
     Required by:
         project :expo-modules-core
      > Cannot find a version of 'com.facebook.fbjni:fbjni' that satisfies the version constraints:
           Dependency path 'host.exp.exponent:expo-modules-core:1.11.8' ---> 'com.facebook.fbjni:fbjni:0.5.1'
           Constraint path 'host.exp.exponent:expo-modules-core:1.11.8' ---> 'com.facebook.fbjni:fbjni:{strictly 0.3.0}' because of the following reason: debugRuntimeClasspath uses version 0.3.0
           Dependency path 'host.exp.exponent:expo-modules-core:1.11.8' ---> 'com.facebook.react:react-android:0.72.6' (debugVariantDefaultApiPublication) ---> 'com.facebook.fbjni:fbjni:0.3.0'

   > Could not resolve com.facebook.fbjni:fbjni:0.3.0.
     Required by:
         project :expo-modules-core > com.facebook.react:react-android:0.72.6
      > Cannot find a version of 'com.facebook.fbjni:fbjni' that satisfies the version constraints:
           Dependency path 'host.exp.exponent:expo-modules-core:1.11.8' ---> 'com.facebook.fbjni:fbjni:0.5.1'
           Constraint path 'host.exp.exponent:expo-modules-core:1.11.8' ---> 'com.facebook.fbjni:fbjni:{strictly 0.3.0}' because of the following reason: debugRuntimeClasspath uses version 0.3.0
           Dependency path 'host.exp.exponent:expo-modules-core:1.11.8' ---> 'com.facebook.react:react-android:0.72.6' (debugVariantDefaultApiPublication) ---> 'com.facebook.fbjni:fbjni:0.3.0'

临时解决方案是修改expo-modules-core的android/build.gradle添加依赖,但这种修改node_modules的方式不可持续,每次npm install或yarn install后都会被覆盖。

原因分析

冲突根源在于:

  • Expo 50.0.3配套的expo-modules-core 1.11.8依赖com.facebook.fbjni:0.5.1
  • 项目中存在其他依赖(比如旧版react-android:0.72.6)拉取了com.facebook.fbjni:0.3.0
  • Gradle的版本约束机制无法同时满足这两个版本要求,导致解析失败

正确解决方案

方案1:强制统一fbjni版本

在项目根目录的android/build.gradle中,给所有配置添加版本强制策略,统一使用expo-modules-core要求的0.5.1版本:

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

    configurations.all {
        resolutionStrategy {
            // 强制所有依赖使用fbjni 0.5.1
            force 'com.facebook.fbjni:fbjni:0.5.1'
        }
    }
}

方案2:对齐React Native版本

错误日志中显示react-android版本为0.72.6,但Expo 50.0.3对应的React Native版本是0.73.x,说明项目中可能有第三方库依赖了旧版RN,或者本地RN版本未同步升级:

  • 检查package.json中的react-native版本,确保是0.73.x(Expo 50对应的RN版本)
  • 运行npx expo install --fix自动修复依赖版本不匹配问题
  • 若有第三方库依赖旧版RN,尝试升级该库到适配RN0.73的版本

方案3:清理重构原生配置

如果是使用Expo managed workflow,执行以下命令清理旧的原生构建文件,重新生成适配Expo 50的原生配置:

npx expo prebuild --clean

验证

修改配置后,执行以下命令清理缓存并重新构建:

cd android && ./gradlew clean
cd .. && npx expo run:android

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.01 18:40:53