Debugging Android devices on Linux

Often working with custom-built Android hardware, we’ve found that it can sometimes be tricky to enable debugging on our devices through ADB on Linux. Drilling into the problem, we’ve found that simply looking up the vendor ID with lsusb and adding a udev rule is sufficient. This can be especially useful if you’re working with an off-brand device, for which drivers may not be available.

Steps to enable debugging

Here are the steps to do get your device to show up in the Android Debug Bridge (ADB) and enable debugging Android devices on Linux:

  1. Obtain the 51-android.rules device configuration for Linux. Inside, you should find various configurations, such as:

    #Google
    SUBSYSTEM=="usb", ATTRS{idVendor}=="18d1", MODE="0660", GROUP="plugdev"
    

    Here, 18d1 signifies the vendor ID. A comprehensive list can be found on the Android devleoper site, but you should be sure that your device is listed as well.

    To check, execute lsusb in a shell. You may see a listing as follows:

    Bus 002 Device 005: ID 18d1:0003 Google Inc.
    

    Take note of the ID in the format XXXX:XXXX; we’re interested in the first four hexadecimals.

  2. Execute the following command to change the file permissions:

    chmod a+r /etc/udev/rules.d/51-android.rules
    
  3. Unplug the device.

  4. Notify udev of the new device:

    udevadm trigger --action=change
    
  5. Plug in the device.

  6. Kill and restart ADB to check if the device is now registered correctly:

    adb kill-server && adb devices
    

We’ve only tested this in Ubuntu and Mint. If you have anything to add about debugging Android devices on Linux, feel free to add it in the comment section below!

Share