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

Expo构建Android APK时出现404错误,寻求排查与解决方案

Expo构建Android APK报404错误的排查方法与替代方案

问题背景

使用Expo开发React Native应用,在Expo Go中运行正常,但构建Android APK时,Expo CLI与EAS CLI均抛出Request failed with status code 404错误,安装后的应用启动几秒即自动关闭。已尝试更新依赖、检查项目配置、更换构建命令等操作,问题未解决。

项目配置(app.json)

{
  "expo": {
    "name": "GreenApp",
    "slug": "GreenApp",
    "version": "1.0.0",
    "orientation": "portrait",
    "icon": "./assets/icon.png",
    "userInterfaceStyle": "light",
    "splash": {
      "image": "./assets/splash.png",
      "resizeMode": "contain",
      "backgroundColor": "#ffffff"
    },
    "assetBundlePatterns": [
      "**/*"
    ],
    "ios": {
      "supportsTablet": true
    },
    "android": {
      "adaptiveIcon": {
        "foregroundImage": "./assets/adaptive-icon.png",
        "backgroundColor": "#ffffff"
      },
      "package": "com.anandasok.GreenApp"
    },
    "web": {
      "favicon": "./assets/favicon.png"
    },
    "extra": {
      "eas": {
        "projectId": "f7cec193-dafc-44cf-9ab9-2ced15e7786b"
      }
    }
  }
}

错误栈信息

Request failed with status code 404
Error: Request failed with status code 404
    at createError (/usr/local/lib/node_modules/expo-cli/node_modules/axios/lib/core/createError.js:16:15)
    at settle (/usr/local/lib/node_modules/expo-cli/node_modules/axios/lib/core/settle.js:17:12)
    at IncomingMessage.handleStreamEnd (/usr/local/lib/node_modules/expo-cli/node_modules/axios/lib/adapters/http.js:260:11)
    at IncomingMessage.emit (node:events:525:35)
    at endReadableNT (node:internal/streams/readable:1359:12)
    at processTicksAndRejections (node:internal/process/task_queues:82:21)

404错误排查与解决步骤

  • 验证EAS项目关联状态

    1. 执行eas whoami确认登录的Expo账号与项目所属账号一致
    2. 执行eas project:info检查输出的项目ID是否与app.json中extra.eas.projectId匹配,若不匹配,执行eas init重新关联项目(会自动更新app.json的projectId)
  • 清理本地缓存与依赖

    1. 删除本地依赖文件:rm -rf node_modules package-lock.json
    2. 重新安装依赖:npm install
    3. 清理Expo缓存:expo r -c
    4. 清理EAS构建缓存:eas build:cache:clear
  • 排查网络问题

    1. 关闭代理、VPN,切换至稳定的网络环境重试构建
    2. 确认本地防火墙未拦截Expo相关服务域名
  • 更新CLI版本

    1. 卸载旧版本CLI:npm uninstall -g expo-cli eas-cli
    2. 安装最新稳定版:npm install -g expo-cli@latest eas-cli@latest
    3. 执行expo --version、eas --version确认版本为最新
  • 检查项目配置细节

    1. 确认android.package的反向域名格式正确,且与Expo后台项目配置一致
    2. 验证所有资源路径(icon、splash图等)正确,文件存在且无拼写错误

构建Android APK的替代方案

方案1:Expo预构建+本地Android Studio构建

  1. 执行expo prebuild --platform android,生成原生Android项目文件
  2. 用Android Studio打开项目根目录下的android文件夹,等待Gradle同步完成
  3. 依次点击Build > Generate Signed Bundle/APK,按照向导创建签名密钥并生成APK

方案2:EAS调试模式构建

执行eas build -p android --profile development,生成开发环境的APK,该版本会保留更多运行日志,便于定位启动崩溃的具体原因


内容的提问来源于stack exchange,提问作者DEATH x SHOT

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.12 11:33:18