Cannot allocate memory


I have sometimes an issue with my Android build when I execute ./gradlew :app:assemblePrimaryDebugCi -PdisablePreDex --max-workers 2 I encounter this erreor 40% of the time : Cannot allocate memory

My config.yml for this task:
- run:
name: Assemble Debug
command: ./gradlew :app:assemblePrimaryDebugCi -PdisablePreDex --max-workers 2
GRADLE_OPTS: -Xmx1024m -Xms768m
TERM: dumb

What are the good settings to let my build pass ?

Hi there. This blog posts explains all the options and how they can affect your jobs: