Android build fails on createReleaseExpoManifest

🐛 Bug Report

A brand new expo bare-minimum app fails to build for release on Android. It fails during the :app:createReleaseExpoManifest task, because it cannot connect to 127.0.0.1:8081

A workaround is to run react-native start in a separate terminal / process so that the Metro bundler is running. Build will succeed.

Environment

  Expo CLI 3.20.9 environment info:
    System:
      OS: macOS 10.15.4
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 12.16.2 - ~/.nvm/versions/node/v12.16.2/bin/node
      Yarn: 1.22.4 - ~/.nvm/versions/node/v12.16.2/bin/yarn
      npm: 6.14.4 - ~/.nvm/versions/node/v12.16.2/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    IDEs:
      Android Studio: 3.6 AI-192.7142.36.36.6392135
      Xcode: 11.4.1/11E503a - /usr/bin/xcodebuild
    npmGlobalPackages:
      expo-cli: 3.20.9

App target: Android

Steps to Reproduce

First, switch to recent node LTS (12.16.2), and install expo CLI and react-native CLI:

nvm use 12.16.2
npm i -g expo-cli
npm i -g react-native-cli

Then run the following commands to create a fresh bare minimum app and attempt to create an android bundle release:

expo init --template bare-minimum ExpoRNDebug
cd ExpoRNDebug
cd android
./gradlew bundleRelease

Expected Behavior

BUILD SUCCESSFUL

Actual Behavior

> Task :app:createReleaseExpoManifest FAILED
events.js:287
      throw er; // Unhandled 'error' event
      ^

Error: connect ECONNREFUSED 127.0.0.1:8081
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16)
Emitted 'error' event on ClientRequest instance at:
    at Socket.socketErrorListener (_http_client.js:426:9)
    at Socket.emit (events.js:310:20)
    at emitErrorNT (internal/streams/destroy.js:92:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  errno: 'ECONNREFUSED',
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 8081
}
w: Detected multiple Kotlin daemon sessions at build/kotlin/sessions

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:createReleaseExpoManifest'.
> Process 'command 'node'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.6.3/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 2m 15s
430 actionable tasks: 430 executed

Workaround

Run react-native start in a separate terminal / process so that the Metro bundler is running. Build will succeed.

5 thoughts on “Android build fails on createReleaseExpoManifest

  1. @brentvatne I am trying to have my builds automated with AppCenter. Currently AppCebter works fine with a regular react native app. But, with Expo bare it fails with the error above. how would we have metro running in this case or what would be a workaround in this case?

  2. Hey @dondragon2 – we will add a clearer error message here but unfortunately, builds with expo-updates installed do currently require that the metro bundler server is running in another process. The templates from expo init have expo-updates preinstalled because we anticipate most users will want this functionality, but you can remove it if needed.

    If you can customize how you start your build and/or have a separate process running in App Center, it shouldn’t be a problem, but if not, you may need to uninstall expo-updates to get the build to run.

    It’s on our roadmap to get builds with expo-updates running without the need for a packager server. But that’s unfortunately not the case right now 😞 Sorry for the trouble!