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

启用New Architecture后Expo Modules(expo-constants等)在Android端报错的问题求助

启用New Architecture后Expo Modules(expo-constants等)在Android端报错的问题求助

大家好,我遇到了一个困扰已久的问题,想请教下各位开发者:

我刚用npx react-native@latest初始化了一个React Native项目,版本是0.75.1,之后通过npx install-expo-modules@latest安装了最新版的Expo Modules(版本51.0.0),为了测试功能还额外添加了expo-device和expo-constants这两个模块。

目前iOS这边开启新架构(设置RCT_NEW_ARCH_ENABLED=1)后,一切运行正常,Fabric也已经配置为true,没遇到任何问题。

Android端异常情况

但在Android端开启新架构(把gradle.properties里的newArchEnabled设为true)后,虽然编译能正常通过,但app运行时会弹出如下错误:

Invariant Violation: "rnQRScan" has not been registered. This can happen if:

  • Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
  • A module failed to load due to an error and AppRegistry.registerComponent wasn't called.

我已经确认Metro是在当前项目根目录下运行的,也反复重启过Metro服务,但问题依然存在。

另外,如果我把newArchEnabled改回false,不管是编译还是app运行都完全正常,功能也能按预期工作。

有没有朋友遇到过类似的情况?或者知道可能的原因和解决办法吗?

备注:内容来源于stack exchange,提问作者Harry Bauer

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.16 07:39:31