gradle – An error when creating new project in android studio-ThrowExceptions

Exception or error:

Every time I create new project i get this error:

Failed to import new Gradle project: Could not fetch model of type 'IdeaProject' using Gradle distribution ''.
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 guide chapter on the daemon at
Please read below process output to find out more:
Error occurred during initialization of VM
Could not reserve enough space for object heap
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

Consult IDE log for more details (Help | Show Log)

Any Idea?

How to solve:

Start Android Studio, close any open project.

On the right side, click on Configure -> Settings.

On the left side, in Compiler->Gradle set VM Options to “-Xmx512m” (without quotes)

Press OK, then create a project. Worked for me.


64 bit users!

There is a chance Gradel is looking at a 32 bit JDK install. So we need to change that (worked for me).

Start -> type “Environment” -> click “Edit System Environment Variables” -> a dialog will pop up, click the button labeled “Environment Variables” -> locate JAVA_HOME set it to “C:\Program Files\Java\$YOUR_JAVA_VER” where $YOUR_JAVA_VER = jdk1.7.0_21.

If there is no JAVA_HOME you may need to create it, when I read the install Wiki I was told I needed to install it.


Antivirus block Java and Android studio.
Try to close antivirus and check again…


for me it works by setting up environment variable



Go to Project and find gradle.propeties and then find:- “org.gradle.jnmargs” replace this line with followings
org.gradle.jvmargs=-XX:MaxHeapSize\=256m -Xmx256m

Error in stable version of android-studio 2.2


My answer was found with Android Studio 2.2, which released in September of 2016, so the previous answers that are on this post did not work for me. What did work for me, however, is setting Android Studio to use the integrated JDK instead of the JDK 1.8 that I downloaded. Before setting my JDK to the integrated JDK and not the one I downloaded, I got the same errors as detailed in this post.

This can be found in your Default Project Structure settings. enter image description here


Try to decrease setting for max heap space setting in the file


to smaller value. change it to 512M instead of 1024M.

set defaultMx=-Xmx512M


If you are using the latest version of Android Studio (0.2.1 as of this answer), you can go to Android Studio Preferences, expand the Compiler options, and attempt to reduce the maximum allowed memory for the Java Compiler, Groovy Compiler, and Android DX Compiler. Keep reducing until you see a change in outcome. Honestly, it sounds like your computer may just be short on available RAM, and Android Studio may be configured by default to take up a relatively large chunk of memory.


put the option: -Xmx512m in the compiler >> grandle VM options, not in the general compiler VM options, Don’t Replace -ea


I resolved by go to ANDROID_SDKPATH/sdk/build-tools/VERSION/dx.bat edit with some text editor
change set java_exe=


set java_exe=%java_home%\bin\java.exe

or use your java.exe path

and comment

if exist    "%~dp0..\tools\lib\find_java.bat" call    "%~dp0..\tools\lib\find_java.bat"
if exist "%~dp0..\..\tools\lib\find_java.bat" call "%~dp0..\..\tools\lib\find_java.bat"

result like this

set java_exe=%java_home%\bin\java.exe
rem if exist    "%~dp0..\tools\lib\find_java.bat" call    "%~dp0..\tools\lib\find_java.bat"
rem if exist "%~dp0..\..\tools\lib\find_java.bat" call "%~dp0..\..\tools\lib\find_java.bat"
if not defined java_exe goto :EOF

and now it can BUILD SUCCESSFUL


Open Gradle Properties and change the org.gradle.jvmargs=-Xmx1024m.

and then click try again to synchronize Gradle again.

See The Image


You can try:

  • Open your Android Studio >> File >> Settings >> Compiler >> Gradle
  • Set VM Options to -Xmx512m and OK.

Leave a Reply

Your email address will not be published. Required fields are marked *