首页 > 解决方案 > 无法在 android 设备上运行 react native 项目项目

问题描述

这是我的第一个反应项目。我使用npx react-native init Projectname. 项目创建成功,一切似乎都很好,直到我尝试运行 with react-native run-android,它给出了以下错误:

info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 967 file(s) to forward-jetify. Using 4 workers...
info JS server already running.
'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...

FAILURE: Build failed with an exception.

2 秒内构建失败:

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

我的 android 设备与 USB 连接,但它也说 android 设备未连接。我也在 react-native start另一个 cmd 窗口中做了并在另一个窗口中运行react-native run-android,但它没有工作。

标签: androidreactjsreact-nativegradlereact-native-android

解决方案


推荐阅读