Skip to main content

USB debugging in Linux

To test your android apps which are under development, you can use the emulators or actual phones. Emulators are slow and not very flexible. So better option is connect a phone to your android studio and test the app on that.

How do we enable this -   debugging of the app using phone? In Linux platform, it is easier. You don't need to download any software to your laptop.

The two step process is as follows.

Step 1 : Enable usb debugging in the phone


To enable usb debugging, you have to reveal and enable developer options in your phone. You have to go to settings and some where in the menu, you will get build number. You need to tap it 7 times. Now Developer options are enabled and shown in your menu.

In developer options, enable usb debugging. 

Step 2 : Add the Vendor id of your phone to udev rules file

Connect your phone using usb port. Now give lsusb command. It will list all usb devices connected.


 lsusb
Bus 001 Device 006: ID 0bda:0129 Realtek Semiconductor Corp. RTS5129 Card Reader Controller
Bus 001 Device 005: ID 0a5c:21d7 Broadcom Corp. BCM43142 Bluetooth 4.0
Bus 001 Device 023: ID 2717:ff80 
Bus 001 Device 024: ID 093a:2510 Pixart Imaging, Inc. Optical Mouse
Bus 001 Device 002: ID 8087:8000 Intel Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub


You can identify, line belonging to your phone. In this case, it is 3rd line. You can see the vendor id and product id as 2717 and ff80.

Now you have to create a new file (if it does not already exist.) in the path /etc/udev/rules.d called 51-android.rules. Add the the following line to the file 51-android.rules

SUBSYSTEM=="usb", ATTR[idVendor}=="2a96",  MODE="0666", GROUP="plugdev"

Now save the file and reload these rules for udev using the command

sudo udevadm control --reload


Lo, now you can connect your phone and adb and android studio will recognize your device.


Comments