Just add
android { .... dexOptions { // Prevent OutOfMemory with MultiDex during the build phase javaMaxHeapSize "4g" } }
in your build.gralde
dexOptions { javaMaxHeapSize "4g" }
References
http://stackoverflow.com/questions/37203884/increasing-the-gradle-heap-size