How to set the vendor ID of ADB and trace its internal logs

Setting Vendor ID for ADB

Each Android device has a Vendor ID and a Product ID. If "adb devices" doesn't recognize a connected device, you may need to configure ADB so that it can recognize the specific vendor id on the phone. The vendor ID can be seen with the "lsusb" command. For example:

$ lsusb
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 002: ID 22b8:41db Motorola PCS
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

The vendor id is 22b8 and the product id is 41db. Sometimes, it is recommended that a device node in /dev be automatically created by creating a udev rule, so that adb can find the device. This can be done by creating a file /etc/udev/rules.d/50-android.rules with containing following information:

SUBSYSTEM=="usb", ATTRS{idVendor}=="22b8", SYMLINK+="android_adb", MODE="0666", OWNER="<username>"

Then, change the file permission and restart udev:

$ sudo chmod a+r /etc/udev/rules.d/50-android.rules
$ sudo /etc/init.d/udev restart

With this done, udev will create a link "/dev/android_adb" when the device with the vendor ID 22b8 is plugged in, and thus, adb can find the device without knowing its vendor ID.

An alternative way of letting adb find the device is to create the file ~/.android/adb.ini and add the vendor id in it like:


The first line is the count of listed vendor IDs, followed by the vendor IDs to be supported (it seems that the first line may also be omitted, leaving a vendor ID per line). With this config file, adb can also find the Android device by enumerating the usbdevfs.

Tracing ADB

This is not talking about getting Android logs or traces with "adb logcat", but tracing the execution of adb itself. The adb executable can run in two modes: a front-end client, or a background daemon communicating with devices or emulators. The front end can run as any user, but the daemon needs to run as root. This is why adb needs to be run by root the first time when the daemon needs to be started.

To trace ADB, one can set the environment variable

$ export ADB_TRACE=all

The traces from the ADB front-end will be shown on the screen, and the traces from the server will be saved in /tmp/adb.log.


Developing on a device:
About udev:

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License