首页 > 解决方案 > 命令失败:gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

问题描述

我是 react-native 开发的新手。我正在尝试来自 Facebook git hub 的一个简单的 react-native 项目。我已按照所有步骤操作,但是当我尝试通过键入来运行项目时

  react-native run-android

它只是向我显示以下错误:

   info Running jetifier to migrate libraries to AndroidX. You can  disable it using "--no-jetifier" flag.
   Jetifier found 864 file(s) to forward-jetify. Using 4 workers...
   info Starting JS server...
   info Launching emulator...
   info Successfully launched emulator.
   info Installing the app...
   Warning: No leading - on line 1 of `C:\Program Files\Java\jdk-13\lib\jvm.cfg'

   error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
   Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
   Warning: No leading - on line 1 of `C:\Program Files\Java\jdk-13\lib\jvm.cfg'

at checkExecSyncError (child_process.js:611:11)
at execFileSync (child_process.js:629:15)
at runOnAllDevices (C:\Users\Toshiba\Documents\AwesomeProject\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:39)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async Command.handleAction (C:\Users\Toshiba\Documents\AwesomeProject\node_modules\react-native\node_modules\@react-native-community\cli\build\index.js:164:9)

标签: javascriptreact-nativegradle

解决方案


原来我的Java有问题。我卸载了 JDK 和 JRE 并重新安装了最新版本,它对我有用。


推荐阅读