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

React Native运行Android端报错找不到yoga、fbjni等依赖包如何解决?

问题原因

你当前使用的React Native 0.64.2版本依赖的yoga、fbjni组件,以及react-native-video依赖的android-scalablevideoview组件,没有在你配置的maven源中找到对应版本的安装包。

修复步骤

  1. 调整maven源配置
    你注释了jcenter源,但旧版本RN和部分第三方库的依赖仍然托管在jcenter,可在android/build.gradle的allprojects -> repositories块中添加限定范围的jcenter源,仅拉取缺失的三个依赖:
allprojects {
    repositories {
        google()
        mavenCentral()

        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }
        // 新增限定范围的jcenter源
        jcenter() {
            content {
                includeGroup "com.facebook.yoga"
                includeGroup "com.facebook.fbjni"
                includeGroup "com.yqritc"
            }
        }
        maven { url 'https://www.jitpack.io' }
    }
}
  1. 可选:无需引入jcenter的替代方案
    如果你不想引入jcenter源,可在android/app/build.gradle的dependencies块中手动覆盖react-native-video的依赖:
dependencies {
    // 新增覆盖缺失的视频组件依赖,该包已托管在jitpack源
    implementation 'com.github.yqritc:Android-ScalableVideoView:1.0.4'
    // 原有其他依赖内容保持不变
}
  1. 清理缓存重新构建
    依次执行以下命令完成构建:
  • 清理前端依赖缓存:rm -rf node_modules package-lock.json yarn.lock && npm install
  • 清理安卓构建缓存:cd android && ./gradlew clean
  • 重新运行项目:npx react-native run-android

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.07 10:54:03