Build Fails due to Robolectric tests

I have a multi-module Android application and I am running Robolectric tests on one of my modules. The module that has the Robolectric tests fail (Hangs on running the test until it times out after 10 minutes) if it gets executed at the end, but if it is executed at the beginning it passes without any issues.

I have the following in my build.gadle for this module:

unitTests.all {
    maxHeapSize = "1024m"
}

based on recommendations from this doc. I also have the following environment properties in my config.yml

    environment:
      JVM_OPTS: -Xmx2024m
      GRADLE_OPTS: -Xmx1048m -Dorg.gradle.daemon=false
      GRADLE_OPTIONS: --no-daemon --max-workers 2 # This is done to prevent OOM on CI

This is what I get from the logs

> Task :wear:testDebugUnitTest
Too long with no output (exceeded 10m0s)

There are a few other similar questions here (search for “Too long with no output” to find them).

I posted on one recently. I had wondered if their process has spawned processes that CircleCI was waiting to exit, but it seemed not to be the case.

Are you able to add logging to see exactly where it is getting stuck? I wonder if a trace tool, applied via an SSH console, might help? Perhaps that would reveal what kind of operation it is waiting for.

I haven’t tried investigating it further tbh, my current mitigation is to have the app tests executed first. But I will try to add more verbose logs to see what is causing it.

In the meantime if someone else have seen the same issue and route caused it please let me know.