When building a large app, the default memory of the gradle engine is potentially too low (it's at 2GB per default).
The memory can be increased via the build-extras.gradle
file (also see: https://cordova.apache.org/docs/en/latest/guide/platforms/android/#setting-gradle-properties).
The problem with this approach is, that the build-extras.gradle
resides in the platforms/android
directory and will be
deleted if you choose to remove/reinstall the platform.
To solve that, create a build hook that copies the file from your project root.