I have upgraded to Android Studio 2.1 and I got this error while I am trying to build & run my corporate big project:
Execution failed for task \
Another method to set the heap size for particular jobs is to use environment variables for each job. This ensures that the memory is available when the job that requires a higher memory is not in use.
GRADLE_OPTS="-Dorg.gradle.jvmargs=-Xms1024M -Xmx8192M -XX:PermSize=512M -XX:MaxPermSize=2048 -XX:+CMSClassUnloadingEnabled -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8"
JAVA_OPTS="-XX:MaxPermSize=2048M"