New compilation of Android sources is based on jack, a server runing in the background compiling asynchronously the different projects and libraries needed for the overall Android system. Unfortunately by default the maximum memory settings for jack are not suffiction to compile the Android Java sources. This leads to out of memory errors during the compilation process. To avoid that I wrote a litte shell script which starts jack already before I am starting the compilation:

export JACK_SERVER_VM_ARGUMENTS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4g"
./prebuilts/sdk/tools/jack-admin kill-server
./prebuilts/sdk/tools/jack-admin start-server

The Android build system is checking whether there is already a jack server running and is using the alraady started server with the correct settings.