解决Failed to install the app. Make sure you have an Android emulator running or a device connected问题

error Failed to install the app. Make sure you have an Android emulator running or a device connected. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081

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 3s

    at checkExecSyncError (child_process.js:637:11)
    at execFileSync (child_process.js:655:13)
    at runOnAllDevices (/Users/danale/Projects/engageMobile/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:75:39)
    at buildAndRun (/Users/danale/Projects/engageMobile/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:169:41)
    at then.result (/Users/danale/Projects/engageMobile/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:135:12)
    at processTicksAndRejections (internal/process/next_tick.js:81:5)

react-native run-ios会自动为你打开一个模拟器,但react-native run-android不会,重要的一点,类似的命令,不做类似的事情,即打开一个模拟器。
在Android Studio内打开应用程序,然后进入AVD管理器,给Android Studio打开模拟器,然后运行react-native run-android,它就可以正常运行了。

1.检查环境:https://reactnative.dev/docs/environment-setup

2.解决问题:https://stackoverflow.com/questions/57097192/react-native-error-failed-to-install-the-app-make-sure-you-have-an-android-emu

猜你喜欢

转载自blog.csdn.net/m0_48915964/article/details/129012339