Android Studio Gradle Build failed with following message in the log:
Task :AndroidBootstrap:extractDebugAnnotations
Task :AndroidBootstrap:mergeDebugGeneratedProguardFiles UP-TO-DATE
Task :AndroidBootstrap:mergeDebugConsumerProguardFiles UP-TO-DATE
Task :AndroidBootstrap:syncDebugLibJars
Task :AndroidBootstrap:bundleDebugAar
Task :AndroidBootstrap:compileDebugSources
Task :AndroidBootstrap:assembleDebug
Task :AndroidBootstrap:parseReleaseLocalResources
Task :AndroidBootstrap:writeReleaseAarMetadata
Task :AndroidBootstrap:verifyReleaseResources
Task :AndroidBootstrap:bundleLibResDebug NO-SOURCE
Task :AndroidBootstrap:generateReleaseRFile
Daemon will be stopped at the end of the build after running out of JVM memory
Task :AndroidBootstrap:bundleLibRuntimeToJarDebug
Task :AndroidBootstrap:compileReleaseJavaWithJavac
…
at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.lambda$run$0(DefaultPlanExecutor.java:127)
at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:191)
at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:182)
at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:124)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.OutOfMemoryError: Metaspace
Try:
Run with –stacktrace option to get the stack trace. Run with –info or –debug option to get more log output. Run with –scan to get full insights.Get more help at https://help.gradle.org
BUILD FAILED in 3m 1s
FAILURE: Build failed with an exception.
What went wrong:
MetaspaceTry:
Run with –stacktrace option to get the stack trace. Run with –info or –debug option to get more log output. Run with –scan to get full insights.Get more help at https://help.gradle.org
BUILD FAILED in 3m 1s
Solution
Check the jvmargs parameter in file gradle.properties (project root dir):
#The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
You need add the org.gradle.jvmargs line or modify its value to be more larger than current.