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

React Native应用首次启动崩溃、APK加载脚本失败求助

我的React Native项目问题求助

1. 应用首次启动崩溃

执行react-native run-android后,应用在模拟器/设备上完成安装并启动,但首次启动必崩溃;重新打开后可正常运行,但设备重启或应用进程被杀后,再次启动仍会触发首次崩溃。

2. 构建APK后启动报错

构建APK并安装到设备后,应用直接崩溃并显示红屏错误:

Unable to load script. Make sure you're either running Metro (run 'npx react-native start') or that your bundle 'index.android.bundle' is packaged correctly for release.

应用完全无法打开,没有任何绕过错误的可能。

项目依赖配置(package.json)

{
  "name": "Connect",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "lint": "eslint .",
    "start": "react-native start",
    "test": "jest"
  },
  "dependencies": {
    "@react-native-async-storage/async-storage": "^1.24.0",
    "@react-navigation/bottom-tabs": "^6.6.1",
    "@react-navigation/drawer": "^6.7.2",
    "@react-navigation/native": "^6.1.18",
    "@react-navigation/native-stack": "^6.11.0",
    "axios": "^1.7.7",
    "react": "18.2.0",
    "react-native": "0.74.5",
    "react-native-calendars": "^1.1305.0",
    "react-native-dotenv": "^3.4.11",
    "react-native-gesture-handler": "^2.18.1",
    "react-native-linear-gradient": "^2.8.3",
    "react-native-reanimated-carousel": "^3.5.1",
    "react-native-responsive-dimensions": "^3.1.1",
    "react-native-safe-area-context": "^4.11.0",
    "react-native-screens": "^3.34.0",
    "react-native-svg": "^15.6.0",
    "react-native-vector-icons": "^10.2.0"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@babel/preset-env": "^7.20.0",
    "@babel/runtime": "^7.20.0",
    "@react-native/babel-preset": "0.74.87",
    "@react-native/eslint-config": "0.74.87",
    "@react-native/metro-config": "0.74.87",
    "@react-native/typescript-config": "0.74.87",
    "@types/react": "^18.2.6",
    "@types/react-test-renderer": "^18.0.0",
    "babel-jest": "^29.6.3",
    "eslint": "^8.19.0",
    "jest": "^29.6.3",
    "prettier": "2.8.8",
    "react-test-renderer": "18.2.0",
    "typescript": "5.0.4"
  },
  "engines": {
    "node": ">=18"
  }
}

已尝试的无效解决方案

  • 启动应用前先执行npx react-native start
  • 多次重新构建APK
  • 单独执行npm install安装react-native-screens和react-native-safe-area-context
  • 删除node_modules和package-lock.json后重新安装所有依赖
  • 执行npm update并尝试升级/降级部分包版本
  • 执行npx react-native start --reset-cache清除Metro缓存

期望达成的效果

  • 应用首次启动平稳运行,不再崩溃
  • 构建的APK可正常启动运行,无脚本加载错误,无需依赖Metro服务

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.18 05:43:17