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

React Native中TypeError: Cannot read property 'viewManagersMetadata' of null问题求助

解决TypeError: Cannot read property 'viewManagersMetadata' of null(Hermes引擎)问题

问题详情

  • 报错信息:ERROR TypeError: Cannot read property 'viewManagersMetadata' of null, js engine: hermes
  • 触发场景:集成expo-barcode-scanner(11.4.0)和`expo-camera`(12.3.0)后出现
  • 当前依赖版本:
    • "react": "18.1.0"
    • "react-native": "0.70.1"
    • "expo": "^46.0.0"

可行解决方案

1. 清理缓存重启项目

执行命令清除Expo缓存并重启,解决模块加载异常:

expo r -c

2. 补全相机权限配置

在app.json或app.config.js中添加完整的相机权限声明,避免模块初始化失败:

{
  "expo": {
    "permissions": ["CAMERA"],
    "ios": {
      "infoPlist": {
        "NSCameraUsageDescription": "需要访问相机扫描条形码"
      }
    },
    "android": {
      "permissions": ["android.permission.CAMERA"]
    }
  }
}

3. 锁定依赖版本至稳定兼容版

将expo版本锁定为46的最新稳定版,避免版本浮动引发兼容性问题:
修改package.json中的expo字段为:

"expo": "46.0.16"

然后执行安装命令:

npm install
# 或 yarn install

4. 确认Hermes引擎配置

检查android/app/build.gradle中Hermes启用状态,确保配置正确:

project.ext.react = [
  enableHermes: true,
]

若修改过配置,重新构建项目:

expo run:android
# 或 expo run:ios

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.15 12:40:41