Increase the JVM heap size for Gradle

[Why]
The Java Virtual Machine(JVM) maximum heap size(-Xmx) is 512M by default. It will occur out of memory eror when compiling for Android.
Android compiling error: "java.lang.OutOfMemoryError: Java heap space".

[How]
Configure JVM memory for Gradle by setting Gradle property org.gradle.jvmargs in gradle.properties file.
This gradle.properties file was generated by Android Studio settings.

Reference:
https://developer.android.com/build/optimize-your-build?utm_source=android-studio#increase-the-jvm-heap-size
https://docs.gradle.org/7.2/userguide/build_environment.html#sec:configuring_jvm_memory
This commit is contained in:
robotchaoX 2023-05-28 19:37:00 +08:00
parent 240a56e441
commit 9578a603e8

14
android/gradle.properties Normal file
View file

@ -0,0 +1,14 @@
## For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
#
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx1024m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
#
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
#Sun May 28 17:34:07 CST 2023
org.gradle.jvmargs=-Xmx4096M