繁体   English   中英

如何强制 react-native 项目在物理 android 设备上运行?

[英]How to force react-native project to run on a physical android device?

我试图让我的 react-native 项目在物理 android 设备上运行。 当我运行“adb device”时,我得到了一个正确的 output:

List of devices attached
LMX210APMc7ea5434   device
emulator-5554   device

但是,当我运行“react-native run-android”时,我得到了这个:

react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
(node:3285) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
Jetifier found 967 file(s) to forward-jetify. Using 8 workers...
info JS server already running.
/bin/sh: /Users/eugene/Android/Sdk/platform-tools/adb: No such file or directory
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...

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 app:installDebug -PreactNativeDevServerPort=8081

我确实安装了 android 工作室,配置了 SDK,添加了一个 AVD 设备等...

我还通过USB连接设备,进入开发者模式,启用USB调试,运行adb反向等...

我还需要什么才能在设备上运行这个项目?

通常如果我需要在物理设备上运行我的项目,我会关闭我的模拟器。 它在设备上运行没有问题。 你可以使用 npx react-native run-android --deviceId LMX210APMc7ea5434。 adb devices 命令的第一个值是 deviceId。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM