There are numerous reports that adb (Android debug bridge) fails to see Android devices attached to a Fedora box via USB. If you encounter this problem, this guide may give you some hints and ideas about how to set-up adb with workarounds.
1. Install adb
This is simple; just pull it from Fedora's repo:
Code:
$ sudo yum install android-tools
The adb package installs a systemd service (adb.service) which is disabled by default. Usually this is not needed, as adb runs fine as a user-owned daemon process automatically when you start it.
2. Enable USB debugging on the device
This may vary from device to device, and this part is not really related to Fedora. Some phones may lack the option of USB debugging at all. Please refer to the device's support material or online resources. On my Nexus 5 phone, this is done by clicking the "Build number" section in "Settings -> About phone" many times, which unlocks the "Developer options" hidden feature, and selects "USB debugging".
3. Determine the USB ID of the Android device
Install `usbutils' if you don't have it yet:
Code:
$ sudo yum install usbutils
Connect the device to a USB port on the Fedora box and check the device ID using `lsusb':
The output should include your device, with a record that looks like this:
Code:
Bus 003 Device 002: ID 18d1:4ee2 Google Inc. Nexus 4 (debug)
4. Check the permission on the USB device character special file
Code:
$ ls -l /dev/bus/usb/MMM/NNN
where MMM is the No. of "Bus" from the previous section's `lsusb' output, and NNN is the "Device" number from the same line.
If the device is owned by user root and group root, while lacking group- and other- readwrite permission bits, adb as a user-owned process will not have enough permissions to use the device.
(This is usually the problem encountered by the "adb doesn't work" folk 9 of 10 times.)
If this is the case, only the root user will be able to use adb, but using the root user for anything other than basic system configuration is Considered Harmful™. We need to allow user-access on this device.
5. Create a user group and tell udev to create USB device file for this group
First create a group for normal users who should be allowed to access the device:
Code:
$ sudo groupadd androiddev
Here `androiddev' is used as a group name. Of course you can choose your own name for such a group as long as it has not been taken already.
Then add yourself, and all approved users to the group:
Code:
$ sudo usermod -aG androiddev your_login_name
Here `your_login_name' is your own username. Repeat for other users if necessary.
Now, as root, create the file `/etc/udev/rules.d/99-android-debug.rules` and fill it with the following content:
Code:
SUBSYSTEM=="usb", ATTR{idVendor}=="AAAA", ATTR{idProduct}=="BBBB", GROUP="androiddev", MODE="0664"
Replace the `AAAA' and `BBBB' strings with the real Vendor:Product IDs of the device, cf. the output of `lsusb' in Section 3.
6. Refresh group enumeration for yourself
Simply log off and log in again, or use this terrible hack (for your current shell session):
7. Refresh udev rules
Code:
$ sudo udevadm control --reload
$ sudo systemctl restart systemd-udevd.service
Now unplug and plug-in the device again.
8. Check
Now, as your own normal user, issue the command
At this moment, the device should prompt you for checking the computer's RSA key. To verify the key by fingerprint, check the output of this command:
Code:
$ cut -d' ' -f1 ~/.android/adbkey.pub | base64 -d | md5sum
If the output MD5 hash matches the one displayed on the device's screen, you're OK to store and accept the key.
After that, `adb devices' command should give you something like this in the output:
Code:
List of devices attached
0011223344aabbcc device
P.S.
There is no need to practise the voodoo stuff such as turning the device off and on, turning the computer off and on, repeatedly unplugging/changing USB ports, repeatedly killing and restarting adb, upgrading Android SDK, cycling through the device's debug permissions, starting adb with root privilege, sacrifice a lamb and limb, etc., as suggested all over the Internet. See also: Skinner's pigeons.