解决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 will automatically open an emulator for you, but react-native run-android will not, the important point, similar commands, do not do similar things, namely open an emulator.
Open the app inside Android Studio, then go into the AVD manager, open the emulator for Android Studio, then run react-native run-android and it should work fine.

1. Check the environment: https://reactnative.dev/docs/environment-setup

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

Guess you like

Origin blog.csdn.net/m0_48915964/article/details/129012339
Recommended