当我运行CMD> React-Native Run Android指导我解决此问题时,我会遇到以下错误。
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:installDebug'.
> com.android.builder.testing.api.DeviceException: No connected devices!
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 1 mins 27.72 secs
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html
似乎没有连接的设备或无法检测到设备。执行adb devices
查看连接设备的列表。如果没有出现设备,请确保您的仿真器已打开,或者您的设备已连接并启用USB调试模式。
如果无法解决它,请通过运行adb kill-server
和adb start-server
重新启动ADB服务器(如果使用Linux或Mac,则可能需要使用sudo
运行)
但是,如果adb devices
显示未经授权您只需要解锁手机并访问计算机。
上面的错误是连接设备是否连接的
请运行以下命令和检查设备是否连接
adb devices
确保您已打开USB调试。
首先,您必须在物理设备中打开开发人员模式。对于Android,可以在设置时很容易找到(如果您不知道如何打开开发人员模式,请在YouTube上搜索)。
之后运行 adb设备
在MIUI 11中,我发现一段时间后它会自动禁用开发人员模式。因此,您必须重新启用它。