Android Studio + gradle + Windows 7

Android Studio + Windows 7 + gradle = Gradle project sync failed error

I always got the error below in my log file

 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.


I tried many solutions, as clean project, remove .idea file/folder, restart Android Studio, but no one of those worked for me.

After many trials, I got the final solution, and it perfectly works for me! You need to modify the Xmx value, follow the steps:

  1. Control Panel
  2. System
  3. Advanced(tab)
  4. Environment Variables
  5. System Variables
  6. New
 Variable name: _JAVA_OPTIONS
 Variable value: -Xmx512M


…and your nightmare disappears!

Comments are closed.