USB to Android Device
When attaching Android devices on Ubuntu system, they mayn't be recognized by adb directly. Therefore, extra steps are needed to make them ready for usage.
- figure out the device id by lsusb, refer to https://askubuntu.com/questions/166420/how-to-detect-an-usb-device

lsub
# device list
Bus 006 Device 006: ID 18d1:4ee1 Google Inc. Nexus/Pixel Device (MTP)
2. set up device detection on Ubuntu Linux, refer to https://askubuntu.com/questions/863587/adb-device-list-doesnt-show-phone
find or create /etc/udev/rules.d/51-android.rules file, then add a line for the target device. If you do not know your vendor ID, you can get this from lsusb
, it is the string after ID. If lsusb
doesn't report your device, try checking grep USB /var/log/kern.log | less
for vendor ID (for example, a line New USB device found, idVendor=1bbb, idProduct=0167
).
Take care: one vendor has one {idVendor} and {idProduct} for a series of products. For instance, Pixel6 and Pixel8 pro. have shared idVendor and idProduct, so you can check lsusb output and just add one line for Google Pixel devices.
SUBSYSTEMS=="usb", ATTRS{idVendor}=="18d1", ATTRS{idProduct}=="4ee1", MODE="0666" GROUP="androiddev", SYMLINK+="android%n"
Extra error: when using emulators on ubuntu, you may meet with the issue '/dev/kvm' device permission denied. Please refer to https://stackoverflow.com/questions/37300811/android-studio-dev-kvm-device-permission-denied
