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

安装expo-dev-client后Expo Android打包崩溃求助

Expo 49 + expo-dev-client 安卓测试报错解决方案

我在使用Expo 49.0.0版本的项目时,用Expo Go在Android设备上测试应用出现以下错误:

ERROR TypeError: Cannot read property 'expo_module_name' of undefined, js engine: hermes
ERROR Invariant Violation: "main" 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., js engine: hermes

卸载expo-dev-client模块后问题即可解决,未安装该模块时本地打包完全正常,但用yarn expo install expo-dev-client安装~2.4.6版本后就会触发上述错误。我需要该模块进行开发构建,附上完整的package.json文件,希望得到解决办法:

{
  "name": "my_app_name",
  "version": "1.0.0",
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web"
  },
  "dependencies": {
    "@gorhom/bottom-sheet": "4",
    "@react-native-community/datetimepicker": "7.2.0",
    "@react-native-community/slider": "4.4.2",
    "@react-navigation/bottom-tabs": "^6.5.8",
    "@react-navigation/native": "^6.1.6",
    "@react-navigation/native-stack": "^6.9.12",
    "@reduxjs/toolkit": "^1.9.5",
    "@rneui/base": "^4.0.0-rc.7",
    "@rneui/themed": "^4.0.0-rc.7",
    "@types/react-redux": "^7.1.25",
    "async-mutex": "^0.4.0",
    "axios": "^1.3.4",
    "expo": "49.0.0",
    "expo-av": "~13.4.1",
    "expo-dev-client": "~2.4.6",
    "expo-font": "^11.1.1",
    "expo-navigation-bar": "~2.3.0",
    "expo-secure-store": "~12.3.1",
    "expo-status-bar": "~1.6.0",
    "firebase": "^10.1.0",
    "i18next": "^23.2.11",
    "react": "18.2.0",
    "react-hook-form": "^7.45.1",
    "react-i18next": "^13.0.2",
    "react-native": "0.72.3",
    "react-native-flash-message": "^0.4.1",
    "react-native-gesture-handler": "~2.12.0",
    "react-native-input-select": "^1.1.1",
    "react-native-modal-datetime-picker": "^17.0.0",
    "react-native-pager-view": "6.2.0",
    "react-native-reanimated": "~3.3.0",
    "react-native-reanimated-carousel": "^3.4.0",
    "react-native-safe-area-context": "4.6.3",
    "react-native-screens": "^3.20.0",
    "react-native-tab-view": "^3.5.2",
    "react-redux": "^8.1.1",
    "redux": "^4.2.1",
    "redux-thunk": "^2.4.2",
    "typescript": "^5.1.3"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "eslint": "^8.46.0",
    "eslint-plugin-react": "^7.33.1"
  },
  "private": true
}

解决步骤

  • 清理缓存重启Metro
    执行命令彻底清理缓存,再重启开发服务器:

    npx expo start --clear
    

    同时关闭Expo Go,重新打开后扫码连接测试。

  • 升级expo-dev-client到兼容版本
    Expo 49对应的expo-dev-client推荐版本是2.4.10,当前使用的2.4.6可能存在兼容问题,执行升级:

    yarn expo install expo-dev-client@~2.4.10
    
  • 切换到开发构建包测试
    expo-dev-client不能直接配合Expo Go使用,需要生成专属的开发构建包安装到设备:

    1. 生成安卓开发构建:
      npx expo run:android --variant development
      
    2. 构建完成后设备会自动安装该包,后续用这个包连接Metro服务器,而非Expo Go。
  • 排查第三方依赖冲突
    部分第三方库可能和expo-dev-client存在冲突,可临时移除非核心依赖(如react-native-reanimated-carousel、@gorhom/bottom-sheet),逐一测试找出冲突源。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.13 02:55:36