I tried to run react native app with this command.
npx react-native run-android --variant=stagingDebug --appId com.xx_staging
But I am getting this error message. I want to run multiple java versions on my machine. How can I do that? Also I don’t want to change the MaxPermSize=512m. I want to keep MaxPermSize=512m as it is.
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 FilesJavajdk-18.0.2.1binjava.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:Usersrbza9.gradlewrapperdistsgradle-6.7-allcuy9mc7upwgwgeb72wkcrupxegradle-6.7libgradle-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 FilesJavajdk-18.0.2.1binjava.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:Usersrbza9.gradlewrapperdistsgradle-6.7-allcuy9mc7upwgwgeb72wkcrupxegradle-6.7libgradle-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:testxxnode_modulesexecaindex.js:174:9)
at F:testxxnode_modulesexecaindex.js:278:16
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async runOnAllDevices (F:testxxnode_modules@react-native-communitycli-platform-androidbuildcommandsrunAndroidrunOnAllDevices.js:109:5)
at async Command.handleAction (F:[email protected]:192:9)
info Run CLI with --verbose flag for more details.
How can I fix this error?
2
Answers
This option was completely removed between Java 11 and Java 17. If you want to use Java 17 or later you must remove
MaxPermSize=512m
– the JVM will plainly refuse to start if that option is present .Please note that already with Java 8 this option no longer had any effect and can therefore be safely removed even for Java 8. (https://docs.oracle.com/javase/9/migrate/)
The only possible reason to keep this option in some configurations is if you still must support Java 7. But Java 7 is so much outdated that IMHO it is questionable if any time spent supporting Java 7 is time well spent.
The option seems to be decommissioned.
You can add to the command line which starts your app a flag -XX:+IgnoreUnrecognizedVMOptions. In this case, JVM will ignore all unrecognized flags.