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

2

10

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

Peppie answered 29/3, 2017 at 10:47 Comment(2)
Have you solved this? I have a huge mp4 file and keep getting this error too. I have also found this stackoverflow question here, perhaps it can help: #41646247Hylozoism
It doesn't help me as I already tried with @fluffyBatman answer.Peppie
Z
29

Add this at the end of gradle.properties file.

org.gradle.jvmargs=-XX\:MaxHeapSize\=512m -Xmx512m
Zeitler answered 29/3, 2017 at 11:28 Comment(5)
Where i can find gradle.propertiesPeppie
Go to your project directory. It's in the root directory.Zeitler
In my code, there is no gradle.properties file. Need to create it myself?Peppie
If there is none already, then, yeah, go ahead and create one. Take a look here for help stackoverflow.com/a/37389861Zeitler
I have added gradle.properties as you said but no success. I attached screen shot of error, gradle.properties code and the .sqlite file.Peppie
T
0

clean the project and try again

On root folder

cd android

./gradlew clean

cd ..

react-native run-android

Telega answered 11/12, 2019 at 12:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.