当前位置: 首页 > 知识库问答 >
问题:

无法识别的VM选项MaxPermSize=512m,并且在运行React Native Apps时无法创建Java虚拟机

施华奥
2023-03-14

我试着用这个命令运行react native app。

npx react-native run-android --variant=stagingDebug --appId com.xx_staging

但是我收到这个错误消息。我想在我的机器上运行多个java版本。我该怎么做?我也不想更改MaxPermSize=512m。我想保持MaxPermSize=512m。

npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 2228 file(s) to forward-jetify. Using 4 workers...
info Starting JS server...
'"adb"' is not recognized as an internal or external command,
operable program or batch file.
info Launching emulator...
error Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`.
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
info Installing the app...
Starting a Gradle Daemon (subsequent builds will be faster)

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.7/userguide/gradle_daemon.html
Process command line: C:\Program Files\Java\jdk-18.0.2.1\bin\java.exe -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 C:\Users\rbza9\.gradle\wrapper\dists\gradle-6.7-all\cuy9mc7upwgwgeb72wkcrupxe\gradle-6.7\lib\gradle-launcher-6.7.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 6.7
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

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installStagingDebug -PreactNativeDevServerPort=8081

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.7/userguide/gradle_daemon.html
Process command line: C:\Program Files\Java\jdk-18.0.2.1\bin\java.exe -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 C:\Users\rbza9\.gradle\wrapper\dists\gradle-6.7-all\cuy9mc7upwgwgeb72wkcrupxe\gradle-6.7\lib\gradle-launcher-6.7.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 6.7
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

    at makeError (F:\test\xx\node_modules\execa\index.js:174:9)
    at F:\test\xx\node_modules\execa\index.js:278:16
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async runOnAllDevices (F:\test\xx\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:109:5)
    at async Command.handleAction (F:\test\xx\node_modules\@react-native-community\cli\build\index.js:192:9)
info Run CLI with --verbose flag for more details.

如何修复此错误?

共有1个答案

安坚诚
2023-03-14

此选项在Java 11和Java 17之间已完全删除。如果要使用Java 17或更高版本,必须删除<code>MaxPermSize=512m-如果存在此选项,JVM将明显拒绝启动。

请注意,在Java8中,此选项不再有任何效果,因此即使Java8也可以安全移除。(https://docs.oracle.com/javase/9/migrate/)

在某些配置中保留该选项的唯一可能的原因是您仍然必须支持Java 7。但是Java 7太过时了,以至于我怀疑花在支持Java 7上的时间是否值得。

 类似资料:
  • 当我试图操纵齐柏林飞艇 或 我收到以下错误消息。 Java 9安装在我的系统(Ubuntu 16.04)上。

  • 我试图使用命令<code>yarn android</code>编译我的react原生代码,但它在终端上显示了这个错误。我正在使用Linux Pop_OS 21.04和Visual Studio代码。 我已经尝试了一些解决方案,但没有一个奏效。提前谢谢你!

  • 无法识别的VM选项'maxpermsize=256m'错误:无法创建Java虚拟机。错误:发生致命异常。程序将退出。 我读了这篇文章,尝试了所有的方法来解决它,但都无济于事。我确实注意到他的错误与我的有些不同,并认为这可能是为什么我不能用建议的方法解决我的问题。 当我在终端上执行。sh文件时,它打印了:

  • 我使用OpenJDK 17和来自Spring Initializr的Maven Wrapper 3.8.2(Maven project,JAR packaging,Java17,Spring Boot 2.6.0)。没有其他依赖项。 怎么让它运转起来?没有集。

  • -djava.endorsed.dirs=C:\apache\apache-tomcat-9.0.37\endorsed不受支持。通过可升级模块的概念,支持模块化形式的认可标准和独立API。

  • 问题内容: 我在使用以下配置运行Eclipse时遇到问题: eclipse.ini 除添加上面指定的行外,以上配置均有效。可能是什么问题呢? 我从具有4GB内存的Windows 7(64位)计算机上运行eclipse,尽管我在路径中指定的JDK是32位,这很好用。唯一的问题是,如果我添加这些其他配置参数。 问题答案: eclipse.ini中有两个地方,其中包括 做了