Execution failed for task ‘:app:installDebug’. com.android.builder.testing.api.DeviceException: No connected devices!
The error No connected devices! occurs when React Native cannot find any Android device or emulator to run your app on. This can happen if you don’t have a physical device connected or if you haven’t set up an Android emulator.
Step 1: Check if a Device is Connected
Here’s how to resolve this issue:
First, ensure that you have a physical Android device connected or a virtual Android device (emulator) running.
- Connect a Physical Device:
- Make sure your Android device is connected via USB.
- Ensure that Developer Options and USB Debugging are enabled on your Android device. Here’s how:
- Enable Developer Options:
- Go to Settings > About phone > Tap Build number 7 times.
- Enable USB Debugging:
- Go to Settings > Developer options > Enable USB debugging.
- Enable Developer Options:
- Run the following command to ensure your device is detected:
adb devices
- If your device is listed, it’s connected properly.
- Enable USB Debugging for Windows (if required):
- Ensure that ADB drivers are installed on your Windows machine to allow the device to be detected.
- Download and install Google USB Driver from Android Developer Site.
Step 2: Set Up an Android Emulator
If you don’t have a physical device, you can set up an Android emulator in Android Studio. Here’s how to do it:
- Open Android Studio.
- Create an Android Virtual Device (AVD):
- Go to Tools > AVD Manager.
- Click Create Virtual Device.
- Choose a device model (e.g., Pixel 4).
- Select a system image (e.g., a recent version of Android, such as API 29 or 30).
- Follow the prompts to complete the setup.
- Start the Emulator:
- Once the AVD is created, click the green Play button next to your virtual device to start the emulator.
- Verify the Emulator is Running:
- Open Command Prompt and run:
adb devices
- This should list your emulator as a connected device (it will be labeled with something like emulator-5554).
Step 3: Run the React Native App Again
Now that your physical device or emulator is ready, try running the app again:
- Navigate to your React Native project folder:
cd D:\ReactNativeProject\InsuranceApp
2. Run the app:
npx react-native run-android
Step 4: Troubleshooting
If you’re still facing issues, here are a few troubleshooting steps:
- Check Device Connection:
- Run adb devices again to check if the device is listed. If not, unplug and reconnect your device, or restart your emulator.
- Ensure Your Emulator is Running:
- If using an emulator, make sure it’s running and not idle.
- Restart the Metro Bundler:
- Stop the current Metro bundler if it’s running (press Ctrl + C).
- Start it again by running:
npx react-native start
- Rebuild the Project:
- Sometimes clearing build caches can help. Try cleaning the project and rebuilding it:
cd android
gradlew clean
cd ..
npx react-native run-android
These steps should help you get your Android device or emulator connected and running the app. Let me know if you encounter any further issues!
Recent Comments