react native 运行 react-native run-android 启动报错

    在前一天明明开发得很好,react-native run-android一运行就能跑起来,但是第二天开发时运行react-native run-android命令就出现如下错误:

报这个的原因有很多,博主没有仔细找具体原因,由于开发时间紧急,发现一个治标不治本的方法(下面回答),得以继续开发。如有知道具体原因的朋友也可以联系我,我也想知道怎么解决o(╯□╰)o。

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:installDebug'.
> com.android.builder.testing.api.DeviceException: No online devices found.

* 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: 17.847 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:

解决方案:

上面在Terminal里面可以看出,react-native run-android 命令运行报错了,但是server仍然在运行。直接打开你在开发的APP,使用手机摇一摇点击 “reload”,然后就会发现,修改过的代码是直接运行在手机上的(如果你卸载了开发版APP,我也不知道咋办了)。虽然Terminal报错,但是丝毫不影响正常开发,可以直接忽略这些错误,先做开发。

ps:此片文章不能给予大家太多帮助,但是如果出现这样的错误,有又比较急的开发任务,大家可以先忽略这样的问题,让开发先进行下去。

猜你喜欢

转载自blog.csdn.net/qq_33183172/article/details/85125240