DEV Community

Cover image for Running an Android App in React-Native CLI
Rajiv Chaulagain
Rajiv Chaulagain

Posted on

Running an Android App in React-Native CLI

This guide will walk you through the steps to run an Android app using React Native CLI. By following these steps, you can ensure your development environment is properly set up and your application runs smoothly on your connected device.

Steps

Step 1: Check Connected Devices

  1. Connect Your Device:

    • Use a USB cable to connect your PC/Mac to your testing mobile phone.
    • Make sure USB debugging is enabled on your mobile phone.
  2. Check Connected Devices:

    • Open a terminal on your PC/Mac.
    • Run the following command to check the list of connected devices:
adb devices

Enter fullscreen mode Exit fullscreen mode
  • This command will show a list of devices attached. If your device appears in the list, it is correctly connected.

Step 2: Clean Previous Builds

  • Run the following command to clean the previous cache and builds. This helps prevent unwanted bugs:
./gradlew clean

Enter fullscreen mode Exit fullscreen mode

Step 3: Run the React Native App

  • Go back to the root directory of your project:
  • Run the React Native App:
npx react-native run-android

Enter fullscreen mode Exit fullscreen mode
  • Optional: Reset Metro Bundler Cache:
npx react-native start --reset-cache

Enter fullscreen mode Exit fullscreen mode

Step 4: Generate the Debug APK

Build the Debug APK:
By running the previous commands, React Native will create an APK file named debug.apk for testing purposes.

Top comments (0)