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

4

9

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.

Nerland answered 19/10, 2021 at 15:26 Comment(0)
N
17

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

Nerland answered 19/10, 2021 at 15:26 Comment(2)
this doesnt seem to work for me on a mac, Im getting this error in cmd when trying to run an existing react native project.Demetri
what worked for me was the java-sdk version, which I changed and everything works fine, for newer versions of java this is not supported, openjdk version "1.8.0_345" OpenJDK Runtime Environment (build 1.8.0_345-bre_2022_08_04_23_35-b00) OpenJDK 64-Bit Server VM (build 25.345-b00, mixed mode)Demetri
U
25

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

Unloosen answered 30/6, 2023 at 11:48 Comment(2)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Solmization
Dear bot, his answer is good enough and solved my problem. but not to upset you i can say that the relevant file is gradle.propertiesBalikpapan
N
17

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

Nerland answered 19/10, 2021 at 15:26 Comment(2)
this doesnt seem to work for me on a mac, Im getting this error in cmd when trying to run an existing react native project.Demetri
what worked for me was the java-sdk version, which I changed and everything works fine, for newer versions of java this is not supported, openjdk version "1.8.0_345" OpenJDK Runtime Environment (build 1.8.0_345-bre_2022_08_04_23_35-b00) OpenJDK 64-Bit Server VM (build 25.345-b00, mixed mode)Demetri
P
2

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

Here's a screenshort

Propraetor answered 9/2, 2022 at 15:42 Comment(0)
O
1

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.

Oppidan answered 9/11, 2022 at 18:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.