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

Expo集成react-native-video报错:RCTVideo未在UIManager中找到

解决requireNativeComponent: "RCTVideo" was not found in the UIManager错误

问题原因

react-native-video是纯React Native原生模块,在Expo Managed Workflow(非裸项目)中无法直接使用——Expo没有预打包该模块的原生代码,因此运行时找不到对应的RCTVideo组件。

解决方法一:使用Expo官方expo-av组件替代(推荐)

Expo官方提供的expo-av完全适配Expo环境,无需处理原生配置:

  • 安装依赖:
npx expo install expo-av
  • 替换原有代码,使用expo-av提供的Video组件:
import { Video } from 'expo-av';

export default function YourComponent() {
  return (
    <Video
      source={{ uri: "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" }}
      style={{ width: '100%', height: 300 }}
      useNativeControls
      resizeMode="contain"
      shouldPlay
    />
  );
}

解决方法二:转为裸工作流并配置react-native-video

若必须使用react-native-video,需将Expo项目转为裸工作流,手动配置原生代码:

  1. 执行预构建命令,将Managed项目转为裸项目:
npx expo prebuild
  1. 安装react-native-video:
npm install react-native-video
  1. 平台专属配置:
  • iOS:进入iOS目录执行pod安装
cd ios && pod install && cd ..
  • Android:RN 0.60+版本无需额外配置,模块会自动链接
  1. 清除缓存并重启项目:
npx expo start --clear

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.19 11:42:36