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
Add this at the end of gradle.properties
file.
org.gradle.jvmargs=-XX\:MaxHeapSize\=512m -Xmx512m