0

I am having a problem when running Flutter Project I've tried multiple versions of gradle and all the same error

FAILURE: Build failed with an exception.

* What went wrong:
Unable to start the daemon process.
This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized jvm option is used.
Please refer to the User Manual chapter on the daemon at https://docs.gradle.org/5.6.2/userguide/gradle_daemon.html
Process command line: C:\Program Files (x86)\Java\jdk1.8.0_271\bin\java.exe -Xmx1536M -Dfile.encoding=windows-1256 -Duser.country=US -Duser.language=en -Duser.variant -cp C:\Users\midos\.gradle\wrapper\dists\gradle-5.6.2-all\9st6wgf78h16so49nn74lgtbb\gradle-5.6.2\lib\gradle-launcher-5.6.2.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 5.6.2
Please read the following process output to find out more:
-----------------------
Error occurred during initialization of VM
Could not reserve enough space for 1572864KB object heap
2

* 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
Exception: Gradle task assembleDebug failed with exit code 1


Output of Flutter doctor -v

[√] Flutter (Channel stable, 1.22.5, on Microsoft Windows [Version 10.0.19042.685], locale en-US)
    • Flutter version 1.22.5 at C:\flutter
    • Framework revision 7891006299 (12 days ago), 2020-12-10 11:54:40 -0800
    • Engine revision ae90085a84
    • Dart version 2.10.4


[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at C:\Users\midos\AppData\Local\Android\sdk
    • Platform android-30, build-tools 30.0.3
    • Java binary at: C:\Program Files (x86)\Common Files\Oracle\Java\javapath\java.exe
    • Java version Java(TM) SE Runtime Environment (build 1.8.0_271-b09)
    • All Android licenses accepted.

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).

[√] VS Code, 64-bit edition (version 1.52.1)
    • VS Code at C:\Program Files\Microsoft VS Code
    • Flutter extension version 3.17.0

[√] Connected device (1 available)
    • sdk gphone x86 arm (mobile) • emulator-5554 • android-x86 • Android 11 (API 30) (emulator)

! Doctor found issues in 1 category.

output for Java --showversion

java version "1.8.0_271"
Java(TM) SE Runtime Environment (build 1.8.0_271-b09)
Java HotSpot(TM) Client VM (build 25.271-b09, mixed mode)

I tried to change gradle to: gradle-5.6.2-all gradle-6.1.1-all

I tried to add org.gradle.jvmargs=-Xmx1024m in gradle-wrapper.properties

I tried to delete .gradle and build it again

I tried to disable windows defender while building and the same problem

1 Answer 1

4

IMHO your machine is not able to serve the gradle process the heap space it requested.

Error occurred during initialization of VM
Could not reserve enough space for 1572864KB object heap

Means that the JVM running gradle wants 1.5GB Heap from the OS but it doesn't get it.

What you can try:

modify or create the gradle.properties file in the root directory of your build.

set

org.gradle.jvmargs=-Xmx1024M

so your gradle process only consumes 1GB of Memory.

run ./gradlew --stop to stop all your deamons before running the next build.

BUT: please make sure your system has enough memory resources to run all your applications/processes you want to run.

If you your system has enough memory resources: it seems to me you maybe are using a 32 Bit JVM. 32 Bit Java JVMs have quite low memory limits. Please switch to a 64 Bit JVM and make sure your JAVA_HOME Env Variable is pointing to the 64 Bit JVM. This will allow you to allocate much more memory.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.