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

React Native升级至0.70.3后Android端UIManager NativeModule创建失败

React Native 0.70.3升级后Android运行报错的解决思路

错误里提到的com.brentvatne.exoplayer类实际来自react-native-video库,不是你说的react-native-video-with-ads——大概率是你项目里某个依赖包间接引入了旧版react-native-video,和RN 0.70.3的Android API不兼容,导致类验证失败。试试下面这些步骤:

1. 找出间接引入的react-native-video

  • 运行命令排查依赖链:
    # npm用户
    npm ls react-native-video
    # yarn用户
    yarn why react-native-video
    
    输出里会显示是哪个依赖带进来了这个库。

2. 强制统一react-native-video版本

在package.json里添加版本锁定字段,指定兼容RN 0.70.3的版本(推荐6.x系列):

// npm用overrides
"overrides": {
  "react-native-video": "^6.0.0"
}

// yarn用resolutions
"resolutions": {
  "react-native-video": "^6.0.0"
}

然后重新安装依赖:

npm install # 或 yarn install

3. 清理缓存后重新构建

  • 重置RN缓存:
    npx react-native start --reset-cache
    
  • 清理Android构建缓存:
    cd android && ./gradlew clean
    
  • 重新编译运行:
    npx react-native run-android
    

4. 卸载不必要的包

既然你没用到react-native-video-with-ads,先卸载它避免冲突:

npm uninstall react-native-video-with-ads # 或 yarn remove react-native-video-with-ads

5. 检查Reanimated版本兼容性

错误栈里涉及ReanimatedPackage,RN 0.70.x需要搭配Reanimated 2.10.x及以上版本,检查你项目里的react-native-reanimated版本,不兼容就升级到对应版本。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.16 02:01:17