From 9578a603e8c12a5c98a09bce1eff717ecb1e14ae Mon Sep 17 00:00:00 2001 From: robotchaoX Date: Sun, 28 May 2023 19:37:00 +0800 Subject: [PATCH] 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 --- android/gradle.properties | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 android/gradle.properties diff --git a/android/gradle.properties b/android/gradle.properties new file mode 100644 index 00000000..d1e13c17 --- /dev/null +++ b/android/gradle.properties @@ -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