无法在设备上启动没有错误的React Native运行吗?

时间:2018-12-06 20:50:33

标签: android android-studio react-native android-emulator

在Mac OSX上的this教程中运行,我安装了android studio并构建了Nexus 5仿真器(API 27,Android 8.1.0)。运行react-native run-android命令时,如果仿真器通过android studio运行,则不会出现错误,但是该应用不会在仿真器上开始运行。

(注意,上周我在维修分配给我的笔记本电脑,相同的操作系统,都是macbook pro 15的同时,从工作计算机上借用了这笔贷款;该应用程序将在模拟器上自动启动)

如果我在不打开仿真器的情况下运行命令,则会得到以下输出:

JS server not recognized, continuing with build...
Building and installing the app on the device (cd android && ./gradlew installDebug)...

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. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
27 actionable tasks: 1 executed, 26 up-to-date
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/getting-started.html

如果我在仿真器打开的情况下运行命令,则会得到以下输出:

JS server not recognized, continuing with build...
Building and installing the app on the device (cd android && ./gradlew installDebug)...

> Task :app:installDebug 
Installing APK 'app-debug.apk' on 'Nexus_5X_API_27(AVD) - 8.1.0' for app:debug
Installed on 1 device.


BUILD SUCCESSFUL in 2s
27 actionable tasks: 1 executed, 26 up-to-date
/bin/sh: adb: command not found
Starting the app (adb shell am start -n  com.reactcalculator/com.reactcalculator.MainActivity...

模拟器永远不会改变。


解决方案

该应用已在设备上;它只是没有立即开始。我可以通过彻底检查应用列表来找到它。似乎在某些环境(例如上述我的借贷人)中,具有单独启动功能的应用程序在其他环境中需要手动启动。

1 个答案:

答案 0 :(得分:0)

该应用程序存在,只是没有自动启动。

该应用已在设备上;它只是没有立即开始。我可以通过彻底检查应用列表来找到它。似乎在某些环境(例如上述我的借贷人)中,具有单独启动功能的应用程序在其他环境中需要手动启动。