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

Expo EAS构建的APK无法安装且崩溃,Expo Go运行正常

Expo EAS构建APK安装后崩溃排查方案

核心排查与修复步骤

1. 移除Web专属依赖

你的package.json包含多个仅适用于Web项目的依赖,这些依赖在原生Android环境中无法运行,是导致崩溃的高频原因:

  • bootstrap
  • react-bootstrap
  • react-bootstrap-table
  • react-html-table-to-excel
  • react-to-print
  • express-generator

执行命令移除这些无用依赖:

npm uninstall bootstrap react-bootstrap react-bootstrap-table react-html-table-to-excel react-to-print express-generator

2. 解决第三方模块兼容性问题

图标库冲突

同时安装react-native-ionicons和react-native-vector-icons会引发资源冲突,Expo环境推荐使用官方图标库替代:

npm uninstall react-native-ionicons react-native-vector-icons
npm install @expo/vector-icons

自定义Git依赖风险

react-native-table-component使用的第三方分支可能未适配React Native 0.70.5(对应Expo 47),替换为官方稳定版:

npm uninstall react-native-table-component
npm install react-native-table-component@latest

3. 修复依赖版本不匹配

部分依赖版本与Expo 47存在兼容问题:

  • react-native-svg-transformer:当前1.0.0版本不适配Expo 47,降级到0.14.3
  • native-base:3.4.26与Expo 47存在已知冲突,建议升级适配版本或直接使用已安装的@rneui/themed替代

执行版本调整命令:

npm install react-native-svg-transformer@0.14.3

4. 优化EAS构建配置

在eas.json的preview配置中添加调试参数,便于捕获崩溃日志:

"preview": {
  "android": {
    "buildType": "apk",
    "gradleCommand": ":app:assembleDebug"
  },
  "distribution": "internal",
  "ios": {
    "resourceClass": "m-medium"
  }
}

5. 捕获崩溃日志

安装APK后,通过adb命令获取详细错误信息:

adb logcat *:E

验证流程

  1. 清理缓存并重新安装依赖:
npm cache clean --force
rm -rf node_modules package-lock.json
npm install
  1. 重新构建APK:
eas build --platform android --profile preview

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.27 06:10:01