PDA

View Full Version : HowTo: set-up adb (Android Debug Bridge) on Fedora 20



aleph
11th May 2014, 08:36 AM
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:

$ 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:

$ sudo yum install usbutils
Connect the device to a USB port on the Fedora box and check the device ID using `lsusb':

$ lsusb
The output should include your device, with a record that looks like this:

Bus 003 Device 002: ID 18d1:4ee2 Google Inc. Nexus 4 (debug)

4. Check the permission on the USB device character special file

$ 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™ (http://www.catb.org/jargon/html/C/considered-harmful.html). 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:

$ 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:

$ 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:

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):

$ exec su -l $USER

7. Refresh udev rules

$ 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

$ adb devices
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:

$ 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:

List of devices attached
0011223344aabbcc device

P.S.
There is no need to practise the voodoo (http://www.catb.org/jargon/html/V/voodoo-programming.html) 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 (https://en.wikipedia.org/wiki/B._F._Skinner#Superstitious_pigeons).

stevea
11th May 2014, 09:57 AM
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.

+1 x2

That paragraph should be a separate thread or even a topic area. Well said.

nated
4th June 2014, 10:16 PM
In step 7 you need to run the following code to restart udev otherwise it won't work and you will get confused like me:confused:

sudo udevadm control --reload

aleph
5th June 2014, 04:36 AM
In step 7 you need to run the following code to restart udev otherwise it won't work and you will get confused like me:confused:

sudo udevadm control --reload

Thanks for pointing that out :cool:

aatifmoin
4th August 2014, 06:12 AM
I've done everything u said but adb does'nt work although fastboot does work fine:confused:

CronoCloud
4th August 2014, 07:27 PM
Just a quick tip. Make sure to enable debugging in your device before you plug it in to do the lsusb. Some devices report different device numbers depending on if it is enabled or not.

CronoCloud

aatifmoin
7th August 2014, 05:55 PM
I did it all it just doesn't work but as I said, fastboot works well

lexonight
9th February 2015, 12:00 AM
digging up old thread, but this worked for my lg optimus f3 and fedora 21, the debugging mode had to be on for my phone. Thanks

[yourusernamehere@localhost ~]$ adb devices
List of devices attached
LGMS659-3bd9e86 device

pawelveselov
20th March 2015, 04:45 AM
Couldn't get this to work :(


[vps@druid]~$ lsusb|grep -i google
Bus 002 Device 026: ID 18d1:0003 Google Inc.
[vps@druid]~$ ls -la /dev/bus/usb/002/026
crw-rw-r--. 1 root root 189, 153 Mar 19 20:15 /dev/bus/usb/002/026
[vps@druid]~$ cat /etc/udev/rules.d/99-android.rules
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="0003", GROUP="androiddev", MODE="0664"

I did udevadm control --reload and restarted udevadm service, the permission of the device wouldn't change. No combination of 18d1:0003 in /usr/lib/udev/rules.d/* files (not that it should matter).

Not until I ran this:


$ sudo udevadm test --action=add /sys/bus/usb/devices/2-2

the permissions/group changed.

May be the reconnect the device vodoo is necessary, though I'm sure I've done it once through the process, but I might've wrong USB codes then.

I also have no clue on how to figure out the UDEV node paths from the actual devices...

jwehrle
10th July 2015, 05:42 AM
Be sure not only that debugging is "on" but that the "USB debugging" option inside Developer Options (inside settings) is "on"

This may be covered in another entry but I thought I had finished telling my phone I wanted to allow debugging only to find that I had to specifically say yes again.