Unrecognized vm option maxpermsize 512m error could not create the java virtual machine

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: Co...

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.

asked Oct 19, 2021 at 15:26

Pooja Singh's user avatar

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

answered Oct 19, 2021 at 15:26

Pooja Singh's user avatar

Pooja SinghPooja Singh

5331 gold badge3 silver badges16 bronze badges

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

answered Feb 9, 2022 at 15:42

Ishrat Jahan's user avatar

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.

answered Nov 9, 2022 at 18:28

Ace Falobi's user avatar

Ace FalobiAce Falobi

7211 gold badge8 silver badges25 bronze badges

Summary

After running expo run:android, the build fails and gives the error:

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

For some reason though, running expo run:ios works fine, and then pressing a while in the metro bundler cli successfully bundles for android and runs the app in the emulator. I really don’t know what is causing this since I followed all of the setup instructions that I could find in expo’s documentation.

Also, I apologize if the error is on my side, but I have been troubleshooting for a week with no success, and I don’t know where else to go.

Environment

Expo CLI 5.0.3 environment info:
System:
OS: macOS 12.1
Shell: 5.8 — /bin/zsh
Binaries:
Node: 16.13.1 — /usr/local/bin/node
npm: 8.1.2 — /usr/local/bin/npm
Managers:
CocoaPods: 1.11.2 — /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.2, iOS 15.2, macOS 12.1, tvOS 15.2, watchOS 8.3
IDEs:
Android Studio: 2020.3 AI-203.7717.56.2031.7935034
Xcode: 13.2.1/13C100 — /usr/bin/xcodebuild
npmPackages:
expo: ~44.0.0 => 44.0.3
react: 17.0.1 => 17.0.1
react-dom: 17.0.1 => 17.0.1
react-native: 0.64.3 => 0.64.3
react-native-web: 0.17.1 => 0.17.1
npmGlobalPackages:
eas-cli: 0.46.0
expo-cli: 5.0.3
Expo Workflow: bare

Please specify your device/emulator/simulator platform, model and version

Pixel XL API 30

Error output

% EXPO_DEBUG=true expo run:android
adb devices -l
adb -s emulator-5554 emu avd name
adb devices -l
adb -s emulator-5554 emu avd name
Found Application ID in Gradle: com.chukkertv.android
› Building app…
/Users/username/Projects/chukkertv/chukkertv-mobile/android/gradlew app:assembleDebug -x lint -x test —configure-on-demand -PreactNativeDevServerPort=8081 -PreactNativeDevServerPort=8081
Starting a Gradle Daemon, 1 stopped Daemon could not be reused, use —status for details

FAILURE: Build failed with an exception.

  • What went wrong:
    Unable to start the daemon process.
    This problem might be caused by incorrect configuration of the daemon.
    For example, an unrecognized jvm option is used.
    Please refer to the User Manual chapter on the daemon at https://docs.gradle.org/6.9/userguide/gradle_daemon.html
    Process command line: /Library/Java/JavaVirtualMachines/jdk-17.0.2.jdk/Contents/Home/bin/java -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError —add-opens java.base/java.util=ALL-UNNAMED —add-opens java.base/java.lang=ALL-UNNAMED —add-opens java.base/java.lang.invoke=ALL-UNNAMED —add-opens java.prefs/java.util.prefs=ALL-UNNAMED -Xmx2048m -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant -cp /Users/username/.gradle/wrapper/dists/gradle-6.9-all/dooywd8nv05k16orzxge2b1bs/gradle-6.9/lib/gradle-launcher-6.9.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 6.9
    Please read the following process output to find out more:

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

  • Try:
    Run with —stacktrace option to get the stack trace. Run with —info or —debug option to get more log output. Run with —scan to get full insights.

  • Get more help at https://help.gradle.org
    /Users/username/Projects/chukkertv/chukkertv-mobile/android/gradlew exited with non-zero code: 1
    Error: /Users/username/Projects/chukkertv/chukkertv-mobile/android/gradlew exited with non-zero code: 1
    at ChildProcess.completionListener (/usr/local/lib/node_modules/expo-cli/node_modules/@expo/spawn-async/src/spawnAsync.ts:65:13)
    at Object.onceWrapper (node:events:510:26)
    at ChildProcess.emit (node:events:390:28)
    at maybeClose (node:internal/child_process:1064:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)

    at spawnAsync (/usr/local/lib/node_modules/expo-cli/node_modules/@expo/spawn-async/src/spawnAsync.ts:26:19)
    at spawnGradleAsync (/usr/local/lib/node_modules/expo-cli/src/commands/run/android/spawnGradleAsync.ts:83:18)
    at assembleAsync (/usr/local/lib/node_modules/expo-cli/src/commands/run/android/spawnGradleAsync.ts:57:16)
    at actionAsync (/usr/local/lib/node_modules/expo-cli/src/commands/run/android/runAndroid.ts:143:9)

Reproducible demo or steps to reproduce from a blank project

I don’t know if this will be reproducible on a different machine, as I’m sure the error is being cause by the way I installed my dependencies or where they are located or something of that nature, but following these steps reproduces the error for me:

  1. expo init new-project
    ✔ Choose a template: › blank (TypeScript) same as blank but with TypeScript configuration

    cd new-project

  2. Open up android emulator

  3. expo run:android
    ✔ What would you like your Android package name to be? … com.username.newproject

    (this gives me the error again)

Now let’s try to run an ios simulator then open android from metro cli.

  1. expo run:ios
    ✔ What would you like your iOS bundle identifier to be? … com.username.newproject

  2. Once the build succeeds and the app launches in an ios simulator, go to the metro bundler cli and press the a key

Well, upon trying to reproduce this part, I got a different outcome. Instead of the android app starting up as expected, I received a new error, so hopefully this might provide some insight:
› Opening on Android...
› Opening com.username.newproject://expo-development-client/?url=http%3A%2F%2F10.1.10.239%3A8081 on Pixel_XL_API_30
Couldn't start project on Android: Error running adb: The development client (com.username.newproject) for this project is not installed. Please build and install the client on the device first. Learn more: https://docs.expo.dev/clients/distribution-for-android/

The link brings me to a page that informs me to use the expo run:android command to start an android dev build, or to use the eas cli, which I have already tried unsuccessfully in the past, hence I am now trying to build locally. (As an aside, the issue I had with eas was unrelated to this one. The android build was successful but I was getting a build error for ios 🙃)

Я использую OpenJDK 17 с Maven Wrapper 3.8.2 из Spring Initializr (проект Maven, упаковка JAR, Java 17, Spring Boot 2.6.0). Никаких дополнительных зависимостей.

user@DESKTOP-U2OU5HG MINGW64 /c/Projects/my-project (master)
$ java -version
openjdk version "17" 2021-09-14
OpenJDK Runtime Environment (build 17+35-2724)
OpenJDK 64-Bit Server VM (build 17+35-2724, mixed mode, sharing)

При запуске любого из ./mvnw.cmd -version или ./mvnw.cmd clean install я всегда получаю следующее сообщение:

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

Переход на OpenJDK 16.0.2 решает проблему, однако мне нужно работать с Java 17.

Как заставить его работать? Нет нигде установлен MaxPermSize=512m.

1 ответ

Лучший ответ

Действительно, -XX:MaxPermSize=size помечен следующим образом в соответствии со спецификациями инструмента Java® Development Kit версии 16/17 (см. Ссылки):

  • Для Java 16 это устарело.
  • Для Java 17 это удалено.

Однако Maven Wrapper в скрипте mvnw.cmd, помимо обязательного JAVA_HOME, использует также набор необязательных переменных среды, таких как M2_HOME, и они начинаются с Префикс MAVEN_.

Важным является MAVEN_OPTS, где такая удаленная опция Java может появиться, что приведет к невозможности запуска JVM в более новой версии. В моем случае у меня было что-то вроде:

MAVEN_OPTS="-Xmx4g -XX:MaxPermSize=512m -Dfile.encoding=UTF-8"

Решение состоит в том, чтобы либо удалить параметр из переменных среды, либо добавить эту строку в сценарий Maven Wrapper, чтобы переопределить значение MAVEN_OPTS. В минимальной форме:

MAVEN_OPTS=


16

Nikolas Charalambidis
10 Июн 2022 в 05:25

Open the file pycharm64.vmoptions

nano /opt/pycharm-community-4.5/bin/pycharm64.vmoptions

and add a # at the beginning of the line

# -XX:MaxPermSize=350m

Open the file pycharm.vmoptions

nano /opt/pycharm-community-4.5/bin/pycharm.vmoptions

and add a # at the beginning of the line

# -XX:MaxPermSize=250m

MaxPermSize support was removed in Java 8.0, but the error message

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

does not look like Oracle Java 8 or OpenJDK 8.

The PyCharm starter pycharm.sh tries to find Java:

# ---------------------------------------------------------------------
# Locate a JDK installation directory which will be used to run the IDE.
# Try (in order): PYCHARM_JDK, ../jre, JDK_HOME, JAVA_HOME, "java" in PATH.
# ---------------------------------------------------------------------
if [ -n "$PYCHARM_JDK" -a -x "$PYCHARM_JDK/bin/java" ]; then
  JDK="$PYCHARM_JDK"
elif [ -x "$IDE_HOME/jre/bin/java" ] && "$IDE_HOME/jre/bin/java" -version > /dev/null 2>&1 ; then
  JDK="$IDE_HOME/jre"
elif [ -n "$JDK_HOME" -a -x "$JDK_HOME/bin/java" ]; then
  JDK="$JDK_HOME"
elif [ -n "$JAVA_HOME" -a -x "$JAVA_HOME/bin/java" ]; then
  JDK="$JAVA_HOME"
else
  JAVA_BIN_PATH=`which java`
  if [ -n "$JAVA_BIN_PATH" ]; then
    if [ "$OS_TYPE" = "FreeBSD" -o "$OS_TYPE" = "MidnightBSD" ]; then
      JAVA_LOCATION=`JAVAVM_DRYRUN=yes java | "$GREP" '^JAVA_HOME' | "$CUT" -c11-`
      if [ -x "$JAVA_LOCATION/bin/java" ]; then
        JDK="$JAVA_LOCATION"
      fi
    elif [ "$OS_TYPE" = "SunOS" ]; then
      JAVA_LOCATION="/usr/jdk/latest"
      if [ -x "$JAVA_LOCATION/bin/java" ]; then
        JDK="$JAVA_LOCATION"
      fi
    elif [ "$OS_TYPE" = "Darwin" ]; then
      JAVA_LOCATION=`/usr/libexec/java_home`
      if [ -x "$JAVA_LOCATION/bin/java" ]; then
        JDK="$JAVA_LOCATION"
      fi
    fi

    if [ -z "$JDK" -a -x "$READLINK" -a -x "$XARGS" -a -x "$DIRNAME" ]; then
      JAVA_LOCATION=`"$READLINK" -f "$JAVA_BIN_PATH"`
      case "$JAVA_LOCATION" in
        */jre/bin/java)
          JAVA_LOCATION=`echo "$JAVA_LOCATION" | "$XARGS" "$DIRNAME" | "$XARGS" "$DIRNAME" | "$XARGS" "$DIRNAME"`
          if [ ! -d "$JAVA_LOCATION/bin" ]; then
            JAVA_LOCATION="$JAVA_LOCATION/jre"
          fi
          ;;
        *)
          JAVA_LOCATION=`echo "$JAVA_LOCATION" | "$XARGS" "$DIRNAME" | "$XARGS" "$DIRNAME"`
          ;;
      esac
      if [ -x "$JAVA_LOCATION/bin/java" ]; then
        JDK="$JAVA_LOCATION"
      fi
    fi
  fi
fi
  1. $PYCHARM_JDK
  2. $IDE_HOME/jre/bin/java
  3. $JDK_HOME
  4. $JAVA_HOME

Make sure you are using the Java version that you’d like to use.

Понравилась статья? Поделить с друзьями:
  • Unrecognized vm option maxpermsize 128m error could not create the java virtual machine
  • Unrecognized upnp response ошибка upnp wizard
  • Unrecognized tag minecraft ошибка
  • Unsupported operand type s for int and nonetype как исправить
  • Unrecognized option xincgc error could not create the java virtual machine