首页 > 解决方案 > 尝试构建 android 应用程序时出现构建 iOS 捆绑包错误 - expo -react-native

问题描述

我能够使用expo build:android以前构建应用程序。但是,升级到最新的世博会版本后,我收到以下错误:

connect ECONNREFUSED 127.0.0.1:19001
Set EXPO_DEBUG=true in your env to view the stack trace.

我还在日志中看到以下几行:

Publishing to channel 'default'...
Building iOS bundle

我没有将ios添加到我的app.json中,我只需要构建一个android apk。为此,我使用expo build:android -t app-bundle

我还删除package-lock.jsonnode_modules运行了 npm install,但我得到了同样的错误。

expo start在另一个 cmd 上运行,然后运行expo build:android -t app-bundle仍然得到同样的错误

此外,当我清除 expo 缓存时,请参阅以下日志:

Restarting Metro Bundler...
Starting Metro Bundler on port 19001.
Couldn't adb reverse: adb.exe: error: Invalid source port: 'undefined'

标签: react-nativereact-native-androidexpo

解决方案


我自己也遇到过同样的问题并找到了解决方案。Expo 正在寻找未运行的localhost:19001 。只需按照以下步骤操作,它应该可以按预期工作:

  1. 不运行expo start任何终端,一旦它打开浏览器,您将在其中找到此行,即在端口 19001 上启动 Metro Bundler
  2. 现在打开另一个终端实例并运行expo build:android.

推荐阅读