21

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.

enter image description here

Can anybody please help me.

What is missing from my side?

Vladimir Mironov
  • 30,514
  • 3
  • 65
  • 62
Nirav Shah
  • 2,064
  • 5
  • 24
  • 34

8 Answers8

22

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.

nansjlee
  • 417
  • 2
  • 8
19

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.

Dalmas
  • 26,409
  • 9
  • 67
  • 80
6

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

Thomas
  • 61
  • 1
  • Thanks Thomas, I will also try to find a solution on the same way, if it is the only issue. – Nirav Shah May 17 '13 at 12:37
  • Nice 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, :-) – German Latorre Jun 12 '14 at 11:00
5

1.In the Studio, navigate to File-> Settings->Compiler

   In the VM Options text box, paste this line
   -Xmx512m -XX:MaxPermSize=512m
  1. Delete the existing AVD.

  2. Then File->Invalidate Caches/Restart .

  3. After restarting the studio, create a new AVD. Should work fine !

akash89
  • 881
  • 3
  • 12
  • 31
  • what is this file invalidate stands for?, i am having the same problem for android studio on 32 bit machine? – Sandeep Londhe Jul 19 '15 at 15:25
  • Studio 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 – akash89 Jul 20 '15 at 02:41
4

I found the solution in vs-android Issue 15: -dex: could not create the Java virtual machine

Follow this steps:

  1. Run regedit
  2. Go to HKEY_CURRENT_USER
  3. Select Environment
  4. Add a new String Value and enter _JAVA_OPTIONS for Value name
  5. Enter -Xms256m -Xmx512m for Value data
  6. Reboot computer
Owen Blacker
  • 4,117
  • 2
  • 33
  • 70
Victor Yanez
  • 544
  • 4
  • 7
2

In my case, I also change below file.

C:\Program Files\Android\android-studio\bin\studio.exe.vmoptions

but I decreased -XX:MaxPermSize=350m to -XX:MaxPermSize=300m and restarted Android Studio.

coordinate
  • 15,224
  • 6
  • 24
  • 24
1

I was having the same problem. I downloaded and installed JDK 6u43 and set my JAVA_HOME and JDK_HOME environment variables to C:\Program Files (x86)\Java\jdk1.6.0_43. This let me create a project.

Doesn't help if you want to use jdk7, though.

metsfan
  • 131
  • 1
  • 5
1

I was facing this same issue, and I solved it by the following steps:-

  1. Close android studio.
  2. Go to your project folder.
  3. Delete .gradle folder and gradle.properties file.
  4. Now start android studio project and wait while gradle build. It will not show the error.
Adrian Sanguineti
  • 2,455
  • 1
  • 27
  • 29
Gunjan
  • 11
  • 1