命令失败:gradlew.bat应用程序:installDebug -PreactNativeDevServerPort=8081

2ledvvac  于 2023-10-19  发布在  React
关注(0)|答案(4)|浏览(154)

我是React-Native开发的新手。我尝试了一个来自Facebook git hub的简单react原生项目。我已经遵循了所有的步骤,但当我试图运行该项目键入

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)
k7fdbhmy

k7fdbhmy1#

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

wlzqhblo

wlzqhblo2#

尝试这些一次:

1.reopen android studio as admin. build the gradle. if no issue, proceed on
access the android folder of your app. i.e c:\folder\app\android
2.type in gradlew clean
3.run react-native run-android

希望它能帮助

qcbq4gxm

qcbq4gxm3#

如果您使用的是最新版本的Java Development Kit,则需要更改项目的Gradle版本,以便它能够识别JDK。您可以通过转到**{项目根文件夹}\android\gradle\wrapper\gradle-wrapper. properties并更改distributionUrl**值来升级Gradle版本。你可以在这里查看Gradle的lastest releases

jyztefdp

jyztefdp4#

您遇到的错误消息表明,在运行“./gradlew clean”命令时,在React Native中配置项目“:rn-fetch-blob”时出现问题。具体来说,它提到无法从该高速缓存加载位于“D:\D-drive\移动的\mkc-student-app\node_modules\rn-fetch-blob\android\build.gradle”的构建文件的编译类。
要解决此问题,您可以尝试以下步骤:

**2.**导航至以下目录删除Gradle缓存:

  • 对于Windows:C:\Users<your_username>.gradle\caches
  • 对于macOS:/Users/<your_username>/.gradle/caches
  • 对于Linux:/home/<your_username>/.gradle/caches
    **3.**删除该高速缓存后,再次运行“./gradlew clean”命令。

相关问题