23

I was just updated my last Android Studio and got this error:

failed to create jvm error code -4 JVM Path: C:\Program Files\Java\jdk1.7.0_45\jre If you already have a 32-bit JDK installed, define a JAVA_HOME variable in Which is not solved.

UmAnusorn
  • 10,420
  • 10
  • 72
  • 100
Ravindra Pawar
  • 477
  • 1
  • 5
  • 22
  • I told my solution [here](http://stackoverflow.com/questions/39616303/failed-to-create-jvmerror-code-6-android-studio/41678833#41678833) not sure what was the error about – Samir Jan 16 '17 at 14:40
  • I have also [answered on another thread](https://stackoverflow.com/a/66532284/5376073) what was working for me. – Tomislav Brabec Mar 08 '21 at 15:14

8 Answers8

55

Go to C:\Program Files\Android\Android Studio\bin\studio.exe.vmoptions

Open it with notepad. some times it will not be editable so give administrative permission and change the following attributes:

-Xmx512m to -Xmx256m

-XX:MaxPermSize=250m to -XX:MaxPermSize=128m

Or change:

-Xmx750m to -Xmx512m

-XX:MaxPermSize=350m to -XX:MaxPermSize=250m

yvesmancera
  • 2,915
  • 5
  • 24
  • 33
Bhavan Patel
  • 1,755
  • 1
  • 16
  • 30
23

I have rechecked the java path but its not working in my case. So I deleted the Android Studio settings folder in my user folder.

C:\Users\my_username.AndroidStudio

Then re-open Android Studio then everything work fine for me.

In some case is in C:/Users/my_username/.AndroidStudio3.0/studio64.vmoptions.

UmAnusorn
  • 10,420
  • 10
  • 72
  • 100
  • 1
    Changing the vmoptions due to this: http://stackoverflow.com/questions/31350847/android-studio-using-100-cpu-on-an-i7-processor-for-project-rebuild because that hopefully fix the sluggishness of Android build, will cause this error? Unbelievable. Never thought of it. – Neon Warge Jun 17 '16 at 16:31
  • 2
    In my case it was C:/Users/myuser/.AndroidStudio3.0/studio64.vmoptions. It worked – Jesús Cerezuela Zaplana Mar 12 '18 at 09:54
  • I didn't have to delete the whole folder, only the studdio64.vmoptions file. – bernardo.g May 26 '19 at 13:21
  • Deleting VMOPTIONS File and restarting Android Studio again worked but the file was in config directory so better search it inside `.AndroidStudio3.5/` folder because they're moving it around. – vovahost Jun 19 '19 at 12:49
  • 1
    Works great with 3.5 version in my case "failed to create jvm" err started because trying to speed up AStudio went to Help - Edit Custom VM options ... then A.S. created a file called studio64.vmoptions C:/Users/my_username/.AndroidStudio3.5/config/studio64.vmoptions. – MarkT Sep 19 '19 at 18:00
10

For Android Studio 4+ You need to remove «\studio.exe.vmoptions» or «studio64.exe.vmoptions» Here is the path

C:\Users\%USERNAME%\AppData\Roaming\Google\{studio version} 
8

finally I got answer here. You need to change vmoptions file from android studio.

Go to Program files > Android > Android Studio > Bin > android studio.exe vmoptions file.

Open it with notepad and change the following attributes :

Change -Xmx512m to -Xmx256m and -XX:MaxPermSize=250m to -XX:MaxPermSize=128m or

Change -Xmx750m to -Xmx512m and -XX:MaxPermSize=350m to -XX:MaxPermSize=250m

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
Ravindra Pawar
  • 477
  • 1
  • 5
  • 22
7

If you have recently modified Custom VM Options using Help menu, then you should undo your changes or if you have created a new VM options file, remove it. The file can be found on this path:

C:\Users\.AndroidStudio2.1

Majid
  • 13,853
  • 15
  • 77
  • 113
2

just updating my JDK worked for me! :D If it still doesn't work, try updating Android Studio.

  • 4
    How can I update Android Studio if Android Studio didn't open because of this error? Error 4 and 6 doesn't open up the Android Studio for me. Any thoughts? – Neon Warge Jun 17 '16 at 16:27
1

All I had to do was run android studio as an administrator. Just right click on the icon on your desktop (do not try to do it with a shortcut pinned to your taskbar) and click run as administrator.

0

Go to

C:\Program Files\Android\Android Studio\bin\studio64.exe.vmoptions

Delete studio64.exe.vmoptions file

That's what worked for me

wizsab
  • 45
  • 2
  • 8