Refer to this thread
https://code.google.com/p/android/issues/detail?id=197333
Key points as per this thread :-
è About memory: please note that recommended minimum memory for building an Android tree is 16G.
Iè Issues observed on machine with < 16GB RAM:
o Communication error with Jack server
o Out of memory error (version 1.2-rc4 'Carnac'
Once you will move to a 16 GB RAM machine, all such errors should vanish :-)
This is what i have experienced
export USE_NINJA=false it will desable ninja