Error:Execution failed for task ':app:packageDebug' - Java heap space

Ready Android picture Ready Android · Mar 29, 2017 · Viewed 13k times · Source

I am getting this error in Android Studio logs when I am trying to build an APK.

Error:Execution failed for task ':app:packageDebug'. Java heap space

This issue is coming when I am trying to build an APK with 350 MB size of .sqlite in assets directory. When I removed the .sqlite file then issue is gone.

My studio64.exe.vmoptions file for studio:

-Xms2048m
-Xmx3840m
-XX:ReservedCodeCacheSize=960m
-XX:+UseConcMarkSweepGC
-XX:SoftRefLRUPolicyMSPerMB=250
-da
-Djna.nosys=true
-Djna.boot.library.path=

-Djna.debug_load=true
-Djna.debug_load.jna=true
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
-Didea.paths.selector=AndroidStudio2.3
-Didea.platform.prefix=AndroidStudio
-Didea.jre.check=true

enter image description here

Answer

fluffyBatman picture fluffyBatman · Mar 29, 2017

Add this at the end of gradle.properties file.

org.gradle.jvmargs=-XX\:MaxHeapSize\=512m -Xmx512m