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

Expo Go Android端Manifest非有效JSON,应用启动失败求助

Expo + Tamagui Solito 安卓端启动失败(Expo Go报错/EAS构建崩溃)

问题详情

  • 开发基础:基于Expo搭建跨平台应用,初始采用tamagui solito模板
  • 运行现状:iOS Expo Go、Web端均正常运行;安卓端无法启动
  • 具体异常:
    • Expo Go报错:Uncaught error: java.io.IOException: Manifest string is not a valid JSONObject or JSONArray: <DOCTYPE html>...
    • EAS开发构建包打开即崩溃
  • 环境:Expo服务运行在WSL2环境中
  • eas.json配置:
{
  "build": {
    "development": {
      "distribution": "internal",
      "android": {
        "buildType": "apk"
      },
      "ios": {
        "simulator": true,
        "image": "latest"
      },
      "env": {
        "TAMAGUI_TARGET": "native"
      }
    },
    "production": {
      "distribution": "store",
      "android": {
        "buildType": "app-bundle"
      },
      "env": {
        "TAMAGUI_TARGET": "native"
      }
    }
  }
}

解决步骤

1. 修复WSL2网络访问问题

报错提示Manifest返回HTML,大概率是安卓设备/模拟器无法正确访问WSL2内的Expo服务,获取到错误页而非JSON配置:

  • 在WSL2终端执行hostname -I获取WSL的局域网IP
  • 启动Expo时指定该IP:expo start --host [WSL_IP]
  • 确保安卓设备/模拟器与WSL所在主机处于同一局域网,用上述IP替换默认的localhost连接

2. 验证Manifest有效性

直接检查Expo服务返回的Manifest是否正确:

  • 在WSL2中访问http://[WSL_IP]:8081/manifest.json(端口根据你的Expo实际端口调整),确认返回内容为JSON格式,而非HTML错误页
  • 若返回HTML,排查Next.js/Expo路由配置,确保未拦截/manifest.json请求

3. 调整EAS构建配置

针对EAS构建崩溃问题:

  • 在eas.json的development.android节点中添加"gradleCommand": ":app:assembleDebug",明确调试包构建命令
  • 执行eas build --clear-cache清理构建缓存,避免旧配置干扰
  • 检查android/app/build.gradle文件,排查Tamagui相关依赖冲突

4. 确认Tamagui Native编译配置

确保安卓端Tamagui编译目标正确:

  • 启动Expo时显式指定环境变量:TAMAGUI_TARGET=native expo start --host [WSL_IP]
  • 执行npx tamagui compile重新编译Tamagui组件,确保安卓端代码生成正常

5. 安卓设备/模拟器网络适配

  • 若使用Android Studio模拟器,执行adb reverse tcp:8081 tcp:8081做端口转发,让模拟器通过localhost访问WSL服务
  • 实体设备需关闭Windows防火墙对WSL端口的限制,确保同一局域网内可访问

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.16 10:27:15