Search code examples
react-nativeandroid-emulator

Visual Studio Code + React Native Emulator failing


I am new to React native and using Visual Studio Code for Development. All of a Sudden I am getting error while running the Application (npm run android). Its saying the "Failed to launch Emulator" but still I could see emulator up and running. I have copied full data that I get below. Please guide me how I can resolve the same.

Hello_World@0.0.1 android

react-native run-android

info JS server already running. info Launching emulator... error Failed to launch emulator. Reason: The emulator (Pixel_6_API_30SS) quit before it finished opening. You can try starting the emulator manually from the terminal with: C:\Users\30103061\AppData\Local\Android\Sdk/emulator/emulator @Pixel_6_API_30SS. warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch. info Installing the app...

Task :app:installDebug FAILED Skipping device 'emulator-5554' (emulator-5554): Device is OFFLINE. 38 actionable tasks: 2 executed, 36 up-to-date

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

BUILD FAILED in 10s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Error: Command failed: gradlew.bat 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 online devices found.

  • 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.

BUILD FAILED in 10s

at makeError (C:\Data\Projects\Samples\ASP.NET\React Native\SampleReactNativeApp\Hello_World\node_modules\@react-native-community\cli-platform-android\node_modules\execa\index.js:174:9)
at C:\Data\Projects\Samples\ASP.NET\React Native\SampleReactNativeApp\Hello_World\node_modules\@react-native-community\cli-platform-android\node_modules\execa\index.js:278:16
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async runOnAllDevices (C:\Data\Projects\Samples\ASP.NET\React Native\SampleReactNativeApp\Hello_World\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:82:7)
at async Command.handleAction (C:\Data\Projects\Samples\ASP.NET\React Native\SampleReactNativeApp\Hello_World\node_modules\@react-native-community\cli\build\index.js:108:9)

info Run CLI with --verbose flag for more details.


Solution

  • some steps may help you:

    before run react-native project

    cd C:\Users\30103061\AppData\Local\Android\Sdk\emulator
    
    emulator.exe @Pixel_6_API_30SS
    
    adb devices # you should see Pixel_6_API_30SS is active
    
    npm start -- --reset-cache
    
    npx react-native run-android
    

    if not work another way is to remove your emulator and install another one.