android - 无法在 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.
出了什么问题:无法初始化
class org.codehaus.groovy.runtime.InvokerHelper
尝试:使用
--stacktrace
选项运行以获取堆栈跟踪。--info
使用or选项运行--debug
以获得更多日志输出。运行--scan
以获得完整的见解。在https://help.gradle.org获得更多帮助
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
,但它没有工作。