How To Enable USB Debugging Mode On Android Device

If you want to run an android app automation test using Appium on a physical Android device such as a phone or pad, you need to first enable USB debugging mode in your physical Android device and then connect it with your PC using a data line. Below are steps about how to do that.

1. Step 1: Enable Developer Options.

Below steps are the prerequisites before you can enable USB debugging mode on an android device. If you have already done this step before, then you can go to step 2 directly.

  1. Click the Settings icon on the android OS main screen.
  2. Scroll down in the Settings menu list, check whether there is a menu named ” Developer options ” at the bottom above the About phone menu item, if you can see that option you can type it to disable or enable it. If you can see that option, it also means you have done step-1 before, you can skip step-1 and go to step-2 directly. In my example, I can see that option because I had enabled it before.
  3. If you can not see the ” Developer options ” menu, you should go to the ” About phone ” menu and tap it. The About phone menu is located at the bottom of the Settings menu list.
  4. Scroll down to the ” Build number ” menu item in the ” About phone ” menu list.
  5. You need totally tap seven times on the ” Build number ” menu item, after the first three-tap, it will popup message show you something like ” If you continue tap twice or more you will be a developer “, keep typing until you see another message like ” You are now a developer! “.
  6. Then go back to the Settings menu list, you can see the ” Developer options ” menu item in it.

2. Step 2: Enable USB Debugging Mode.

  1. After enabling the ” Developer options ” menu in step-1, you can enable USB debugging mode now. But what I want to remind you of is that do not make your android phone or pad in USB debugging mode always, just enable it when you needed. There are security risks in that mode because it permits high-level operation on your android device. So to make your android device ( phone or pad ) safe, you should disable this option immediately after you use it.
  2. Type on the ” Developer options ” menu item in the Settings menu list.
  3. Check the ” USB debugging (Debug mode when USN is connected)” checkbox to enable it.
  4. It will prompt you to ask whether ” Allow USB debugging ” or not, click the OK button.
  5. The detailed message of the Allow USB debugging? popup dialog is as below.
    USB debugging is intended for development purposes only. Use it to copy data between your computer and your device, install apps on your device without notification, and read log data.
  6. Now the USB debugging mode has been enabled completed successfully.

3. Step 3: Check Whether Device Is Connected With PC Properly.

  1. Use a USB line to connect your android device with the PC, then you can run the below dos command to verify that the android device in USB debugging mode is connected with the PC properly.
  2. Open dos window.
  3. Execute command ” adb devices ” in the dos window. Then you can see the connected android devices list.
  4. If you can not see any device, maybe it is because of a connection issue or you do not enable USB debugging mode correctly. The most possible reason is that you do not install your android device’s USB driver correctly on your PC. Below are some general android device’s USB driver provider links.
  5. Click here to download the Samsung device USB driver, Click here to download the Lenovo device USB driver, Click here to download the HTC device USB driver. Otherwise, you can go to your phone’s manufacturer’s website to download related USB drivers.

4. Install Google USB Driver In Android SDK Manager.

  1. If you really can not find the correct USB driver for your android device, you can install google’s default USB driver, it can be used to install some android devices.
  2. Launch Android Studio, click the ” Tools —> Android —> SDK Manager ” menu item.
  3. In the pop-up dialog, click Appearance & Behavior —> System Settings —> Android SDK on the left side, then click the SDK Tools tab on the right side, then check the ” Google USB Driver ” checkbox, click Apply button. Then click the Finish button in the next dialog to complete the install.
  4. Click the Windows Start menu, input “device manager” in the windows command input box. Press Enter key.
  5. In the Device Manager window, right-click your portable devices in the path Laptop —> Portable Devices —> Nexus 7 (your portable device).
  6. Click the Properties menu item in the above popup menu list. It will open the detail properties dialog with the title Nexus 7 Properties. Click the Driver tab, then click the ” Update Driver… ” button.
  7. Browse to the Google USB driver saved directory. Commonly you can find the driver in your android SDK installation directory like C:\Users\Jerry\AppData\Local\Android\sdk\extras\google\usb_driver.
  8. After installing google provided USB driver, you can see the connected android device uses adb devices command in the command line.

Now you can run a native android app automation test in your physical android device using Appium and selenium webdriver, we will introduce that in later articles.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.