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

Expo SDK从49升级至51后,嵌套Stack Navigator致App崩溃无报错

问题:Expo SDK 51升级后嵌套Stack Navigator导航崩溃无报错
  • 将React Native Expo应用从SDK 49升级到SDK 51后,初始功能运行正常,但触发嵌套Stack Navigator的导航操作时,应用直接崩溃且无任何错误提示
  • 已更新package.json中所有依赖至最新版本,仍无法捕获到错误信息

以下是当前项目的package.json内容:

{
  "name": "friscohaar",
  "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": {
    "@emotion/react": "^11.11.1",
    "@emotion/styled": "^11.11.0",
    "@expo/vector-icons": "^14.0.0",
    "@mui/icons-material": "^5.15.6",
    "@mui/material": "^5.14.19",
    "@react-native-community/checkbox": "^0.5.17",
    "@react-native-community/datetimepicker": "^7.7.0",
    "@react-navigation/bottom-tabs": "^6.5.11",
    "@react-navigation/native-stack": "^6.9.17",
    "@react-navigation/stack": "^6.3.20",
    "axios": "^1.6.7",
    "expo": "^51.0.1",
    "expo-blur": "^13.0.2",
    "expo-checkbox": "~3.0.0",
    "expo-image-picker": "~15.0.4",
    "expo-linear-gradient": "~13.0.2",
    "expo-location": "~17.0.1",
    "expo-status-bar": "~1.12.1",
    "lodash": "^4.17.21",
    "moment": "^2.29.4",
    "react": "18.2.0",
    "react-native": "0.74.1",
    "react-native-animatable": "^1.4.0",
    "react-native-calendars": "^1.1304.1",
    "react-native-datepicker": "^1.7.2",
    "react-native-dotenv": "^3.4.10",
    "react-native-elements": "^3.4.3",
    "react-native-keyboard-aware-scroll-view": "^0.9.5",
    "react-native-modern-datepicker": "^1.0.0-beta.91",
    "react-native-paper": "5.11.6",
    "react-native-safe-area-context": "^4.10.1",
    "react-native-screens": "~3.31.1",
    "react-native-size-matters": "^0.4.2",
    "react-native-status-bar-height": "^2.6.0",
    "typescript": "^5.1.3"
  },
  "devDependencies": {
    "@babel/core": "^7.24.0",
    "@types/react-native-modern-datepicker": "^1.0.5",
    "babel-plugin-inline-dotenv": "^1.7.0"
  },
  "private": true
}

排查与解决建议

1. 捕获原生层面错误日志

  • 运行应用时开启调试模式:expo start --dev-client,强制触发调试面板,尝试捕获崩溃前的JS层错误
  • 使用Android Studio的Logcat或Xcode控制台查看原生日志,Expo应用崩溃通常会在原生控制台输出完整堆栈信息

2. 验证导航库版本兼容性

SDK 51对应React Native 0.74.x,当前导航库版本可能存在适配问题,尝试升级至最新稳定版:

npm install @react-navigation/stack@latest @react-navigation/native-stack@latest

3. 定位导航配置问题

  • 临时简化导航结构,移除嵌套层级,只保留基础Stack Navigator测试,确认是否仍崩溃
  • 检查路由名称是否存在冲突、嵌套导航容器是否重复注册,或是否有组件未正确接收navigation/route props

4. 清理缓存并重建项目

  • 清理Expo缓存:expo r -c
  • 删除依赖文件后重新安装:
    rm -rf node_modules package-lock.json
    npm install
    
  • 重启开发服务器,重新构建Android/iOS原生项目

5. 排查第三方依赖冲突

  • 执行expo install react-native-screens,安装Expo SDK 51指定版本的react-native-screens,避免版本不匹配
  • 临时禁用非核心第三方组件(如react-native-modern-datepicker、react-native-elements),测试导航功能是否恢复,逐步排查冲突依赖

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.24 03:39:56