Pooja Singh
Pooja Singh

Reputation: 986

Unrecognized VM option 'MaxPermSize=512m' Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit

I updated my IDE to Android Studio Arctic Fox version and was facing this issue when I tried to sync gradle after the upgrade was complete:

"Unrecognized VM option 'MaxPermSize=512m' Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit."

enter image description here

I checked my java version, which was Java 17. I deleted my .gradle directory which didn't help. Reversed the gradle.properties changes made by the update. It didn't work either. I looked for maxPermSize value in my vm.studiooptions file. It wasn't there as suggested in some stackoverflow already asked questions.

Sharing the fix for this below.

Upvotes: 10

Views: 65036

Answers (4)

In JDK 17 -XX:MaxPermSize=size java option has been removed, use -XX:MaxMetaspaceSize instead.

https://docs.oracle.com/en/java/javase/17/docs/specs/man/java.html#removed-java-options

Upvotes: 28

Ace Falobi
Ace Falobi

Reputation: 753

What fixed this for me was changing the JAVA_HOME environment variable on my computer from a JDK 17 version to a JDK 11 version.

I was running some commands that were using my computer's Java environment which was JDK 17 and my project did not support JDK 17.

Upvotes: 1

Ishrat Jahan
Ishrat Jahan

Reputation: 31

In your Android studio go to File--> settings-->(Build, Execution, Deployment)--->Build Tools---> Gradle.
Inside Gradle settings choose Embedded JDK.

Here's a screenshort

Upvotes: 2

Pooja Singh
Pooja Singh

Reputation: 986

After a few hours of looking up for solutions for this online and trying different things.

This worked for me:

File -> Project Structure -> SDK Location -> Last line "JDK location was moved to Gradle settings. I clicked on this -> Gradle JDK -> Embedded JDK

Upvotes: 18

Related Questions