22

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 'http://services.gradle.org/distributions/gradle-1.6-bin.zip'.
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 http://gradle.org/docs/1.6/userguide/gradle_daemon.html
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?

2
  • Did you go into the "Help | Show Log" section there? Also, it's a very early build, not meant for production work, so I don't recommend wasting much time with it if it's giving errors so often.
    – fcm
    Commented May 23, 2013 at 11:19
  • I had this problem yesterday, but today I open the studio and it works. It may be a problem with Internet connection. Try reopen it. Commented May 23, 2013 at 11:42

12 Answers 12

75

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.

4
  • Works for me. Looks like gradle wrapper default is too low.
    – Lal
    Commented Jul 17, 2014 at 14:20
  • This worked for me when I switched from 64-bit JDK to 32-bit JDK and started getting this error.
    – Flyview
    Commented Sep 2, 2014 at 23:36
  • Thanks a lot :) Why Android Studio is not adding default config?
    – Ramesh
    Commented Mar 12, 2015 at 19:29
  • 1
    In Android Studio version 1.2.2, this setting has been moved to Build, Execution, Deployment -> Build Tools -> Gradle Commented Jul 8, 2015 at 19:37
29

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.

2
  • Thanks Tunix, I was missing the JAVA_HOME EV, and this did the trick Commented Aug 29, 2013 at 14:47
  • 3
    This works for me. My JAVA_HOME EV was the 32 bits version. Thanks.
    – wendigo
    Commented Oct 24, 2013 at 15:01
4

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

3
  • Amazing!!! After trying everything here said by many and still no success. I tried to test this and it worked .... god!!! ... weeks lost in the antivirus. For the record I'm using Kaspersky Internet Security 2013
    – xavendano
    Commented Mar 26, 2014 at 16:22
  • If anyone encounters this now - change Antivirus software, a false positive on Java/Android Studio is awful Commented Jul 14, 2014 at 22:10
  • Thank you so much! I tried everything as well, and it's finally fixed! I already disabled McAfee but forgot to also disable Malwarebytes anti-exploit. Thank you so much.
    – rasen58
    Commented Oct 8, 2015 at 21:26
2

for me it works by setting up environment variable

GRADLE_OPTS=-Xmx512m
1

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

1
  • Welcome to Stack Overflow! How to Answer can help you write answers that will be accepted and upvoted.
    – zhon
    Commented Sep 21, 2016 at 5:30
1

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

0

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

android-sdk-windows\platform-tools\dx.bat 

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

set defaultMx=-Xmx512M
1
  • Android studio is Bundle with sdk.
    – Ali
    Commented May 23, 2013 at 11:40
0

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.

0

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

0

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

to

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

0

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

and then click try again to synchronize Gradle again.

See The Image

0

You can try:

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

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.