Android-Studio : Error: Could not create the Java Virtual Machine
Solution 1
In my case, I changed below file to modify vm heap option.
C:\Program Files\Android\android-studio\bin\studio.exe.vmoptions
I increased -Xms128m to -Xms512m and restarted Android Studio.
After that, I could go to next step.
Solution 2
I found a solution to this problem on an old vs-android issue.
You should create a new environment variable named _JAVA_OPTIONS
, set it to
-Xms256m -Xmx1024m
and it should work.
Solution 3
I guess you have the same problem as me. I use Windows 7 32bit and therefore my Java SDK and runtime are also 32 bit. Gradle runs in its own Java VM and Android Studio starts this VM with a heap size parameter (-Xmx1024m) of 1 GB. This is too much for my 32-bit environment and creating the JVM fails.
If I manually start Gradle with -Xmx512m as JVM option Gradle starts without problems, but so far I have not found out how to tell Android Studio to start the JVM differently while it creates a new Android project.
So currently I'm also still stuck.
thomas
Solution 4
1.In the Studio, navigate to File-> Settings->Compiler
In the VM Options text box, paste this line
-Xmx512m -XX:MaxPermSize=512m
Delete the existing AVD.
Then File->Invalidate Caches/Restart .
After restarting the studio, create a new AVD. Should work fine !
Solution 5
I found the solution in vs-android Issue 15: -dex: could not create the Java virtual machine
Follow this steps:
- Run regedit
- Go to
HKEY_CURRENT_USER
- Select Environment
- Add a new String Value and enter
_JAVA_OPTIONS
for Value name - Enter
-Xms256m -Xmx512m
for Value data - Reboot computer
Nirav Shah
Updated on February 08, 2020Comments
-
Nirav Shah about 4 years
I have just installed Android - studio today. First I have to install jdk7 for this IDE.
After that only I was able to launch IDE.
Now When I am trying to create new project, just getting error as shown in below image.
Can anybody please help me.
What is missing from my side?
-
Nirav Shah almost 11 yearsThanks Thomas, I will also try to find a solution on the same way, if it is the only issue.
-
Ivan Ferrer Villa almost 11 yearsthank you! Linked to your answer here: stackoverflow.com/a/16782564/382515
-
Iammesol almost 10 yearsThanks! This worked for me setting both options to -Xms512m and -Xmx512m
-
German Latorre almost 10 yearsNice point about the 32 bit thing. I've configured
C:\Program Files\Android\android-studio\bin\studio.exe.vmoptions
with the values you suggested, killed a few apps, and it worked, :-) -
Sandeep Londhe almost 9 yearswhat is this file invalidate stands for?, i am having the same problem for android studio on 32 bit machine?
-
akash89 almost 9 yearsStudio sometimes can not take up the recent modified files, and at times try to fetch the configurations from the cache, so when you do invalidate think it like, it is clearing all the cache and fetching the current configurations you mentioned. Could you please try the above steps, worked for me and few others.See if this works for you