Why does Gradle time out?

I’m trying to run assembleDevDebug, but i keep getting timeouts.
I don’t know why and can’t found solutions

my circle.yml looks like this:

machine:
  environment:
    _JAVA_OPTIONS: "-Xms512m -Xmx1024m"
    ANDROID_HOME: /usr/local/android-sdk-linux
    GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx4608m -XX:+HeapDumpOnOutOfMemoryError"'

dependencies:
  pre:
    - echo y | android update sdk --no-ui --all --filter "android-25"
    - echo y | android update sdk --no-ui --all --filter "build-tools-25.0.2"
    - echo y | android update sdk --no-ui --all --filter "extra-android-m2repository"
    - echo y | android update sdk --no-ui --all --filter "extra-google-m2repository"
  override:
    - ANDROID_HOME=/usr/local/android-sdk-linux ./gradlew dependencies

  cache_directories:
    - '~/.android'
    - '~/android'
    - '/usr/local/android-sdk-linux/platforms/android-25'
    - '/usr/local/android-sdk-linux/build-tools/25.0.2'
    - '/usr/local/android-sdk-linux/extras/android/m2repository'

checkout:
  post:
    - cp local.properties.ci local.properties

test:
  override:
    - (./gradlew assembleDevDebug -PdisablePreDex -Porg.gradle.parallel=false -Pcom.android.build.threadPoolSize=1 -Dorg.gradle.daemon=false --stacktrace):
      timeout: 1200

and always result timed out like this:

> Building 82% > :app:compileDevDebugKotlin> Building 82%> Building 83% > :app:compileDevDebugJavaWithJavac:app:compileDevDebugJavaWithJavac
> Building 83%> Building 84% > :app:copyDevDebugKotlinClasses:app:copyDevDebugKotlinClasses
> Building 84%:app:compileDevDebugNdk UP-TO-DATE
:app:compileDevDebugSources
:app:mergeDevDebugShaders
:app:compileDevDebugShaders
:app:generateDevDebugAssets
> Building 89% > :app:mergeDevDebugAssets:app:mergeDevDebugAssets
> Building 89%> Building 90% > :app:transformClassesWithJarMergingForDevDebug:app:transformClassesWithJarMergingForDevDebug
> Building 90%> Building 91% > :app:transformClassesWithMultidexlistForDevDebug:app:transformClassesWithMultidexlistForDevDebug
> Building 91%> Building 92% > :app:transformClassesWithDexForDevDebug
command (./gradlew assembleDevDebug -PdisablePreDex -Porg.gradle.parallel=false -Pcom.android.build.threadPoolSize=1 -Dorg.gradle.daemon=false --stacktrace) took more than 10 minutes since last output

Thank you for your reply

Your output indicates to me that Gradle is OOMing. I would lower this value to Xmx3072 because the build only comes with 4 GB of RAM by default.

There are other processes running that take up a bit of RAM and your are also setting JAVAOPTIONS: "-Xms512m -Xmx1024m" When Gradle runs there are typically two java processes, this combination of arguments will always be more than the total of 4GB.

1 Like