Android builds abort with "Lost connection to build agent" message

Bitrise Build Issue Report template

Description of the issue

We have multiple workflows which build fine, except for one, which aborts after about 30 mins to 1 hour. We did two things recently:

  1. upgraded from Android+Docker on Ubuntu 16.0 to 20.04.
  2. upgraded the versions for various steps.


Where did the issue happen?

If on which stack? If not on on what operating system? (Plus any other information you can share)

Which build Step causes the issue and which version of the step?

Build Demo v1.0.0


  • _Does a “Rebuild” help?: NO
  • _Does a rebuild without caches help? : YES, works only after caches are deleted for the main branch.
  • Does the issue happen sporadically, or every time? : Every time
  • Does upgrading the build Step to the latest version help? : NO. All the Steps are at the latest version.
  • When did the issue start? : Oct 5, after the build stack (Android+Docket on Ubuntu) version was upgraded to 20.04

Local reproduction

Can it be reproduced on your own Mac/PC by following our local debug guide? Please follow at least the first section (“Testing with a full clean git clone”) to make sure to test the state of the code what will get when it does a git clone in the clean environment! If possible please note which sections you tried.

Local reproduction: Linux / Android (docker based) stack builds

Can it be reproduced by running the build locally, after doing a new git clone of the repository into the /tmp directory and running the build from there with the Bitrise CLI ( Bitrise CLI )? If no, can it be reproduced with Docker (using the same docker images / environment we use on Related guide: Redirecting… .

Build log

Please try adding a script step to the beginning of your workflow that contains:

#!/usr/bin/env bash

# This is for Linux only!

set -e

# Max memory available
SYSTEM_MEMORY=$(free -m | awk '/^Mem:/{print $2}')

# Keep 2GiB RAM for host (bitirse agent, docker daemon, etc.)

# Only allow Gradle to use up to 80% of RAM outside the 2GiB
# e.g. 4GiB VM will only have 2GiB * 0.8 = 1.6GiB for Gradle
# Tune on smaller instances

mkdir -p "${GRLADE_DIR}"

JVM_MEMORY="-Xmx${GRADLE_MEMORY}m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8"

echo "org.gradle.jvmargs=${JVM_MEMORY}" | tee "${GRLADE_DIR}/"
echo "org.gradle.unsafe.configuration-cache=false" | tee -a "${GRLADE_DIR}/"

envman add --key JAVA_OPTS --value "${JVM_MEMORY}"

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.