Gradle build daemon disappeared unexpectedly in CircleCI
Asked Answered
C

3

6

I use react-native on android. Everything was fine until I upgraded to latest version (0.59.4).

The build keeps failing with "Gradle build daemon disappeared unexpectedly" error on CircleCI. It works fine on local.

I know it's a memory issue and have tried multiple ways to set the java opts and stuff.

environment:
      _JAVA_OPTIONS: '-Xms512m -Xmx3g'
      GRADLE_OPTS: '-Xmx3g -Dorg.gradle.daemon=false -Dorg.gradle.jvmargs="-Xmx3g -XX:+HeapDumpOnOutOfMemoryError"'

Also tried with setting in gradle.properties. None of it is working.

Chokedamp answered 24/6, 2019 at 3:8 Comment(1)
@hannaanessay: did you fix this ? and how ?Wendel
C
1

For all those people who are still facing this. I split my build step into 2 parts.

  1. Bundle the JS Assets

./gradlew bundleReleaseJsAndAssets

  1. Build the app excluding the previous step.

./gradlew assembleRelease -x bundleReleaseJsAndAssets

With these 2 things the Circle CI building worked fine.

Chokedamp answered 22/1, 2020 at 8:28 Comment(0)
G
1

Use resource_class: large in your Circle CI config file. Like this:

jobs:
  release:
    working_directory: ~/myawesomeproject
    docker:
      - image: circleci/android:api-29
    resource_class: large

By defaul Circle CI uses "medium". Gradle runs inside a Java Machine which requires enough space for the Java Heap. And in case there's not enough RAM memory, Circle CI just silently fails which results in "Gradle build daemon disappeared unexpectedly" message.

Link to the doc: Circle CI

Gadolinium answered 20/10, 2023 at 11:50 Comment(0)
H
0

I found a solution here: https://support.circleci.com/hc/en-us/articles/360021812453-Common-Android-memory-issues

For my needs, it was enough to limit max workers and build without spawning a daemon:

gradlew assembleRelease -p android --no-daemon --max-workers 2

but there are a few other tips in that article.

Henke answered 9/4 at 10:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.