Failed to use adb command in Oneplus 5 through Fedora 34

I have:

  • Enabled developer mode from phone tapping build number 8 times.
  • Allowed USB debugging from Developers options.
  • Used original cable which came with the phone.
pranav@fedora ~/Android/Sdk/platform-tools> lsusb
Bus 001 Device 002: ID 8087:8001 Intel Corp. Integrated Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 002 Device 003: ID 04f3:2012 Elan Microelectronics Corp. Touchscreen
Bus 002 Device 002: ID 8087:07dc Intel Corp. Bluetooth wireless interface
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
pranav@fedora ~/Android/Sdk/platform-tools> ./adb devices
List of devices attached

pranav@fedora ~/Android/Sdk/platform-tools>

The problem is my phone only gets the charge from the laptop. It doesn’t respond to PC. Neither distro detect the phone connection as you can see the lsusb output.

What I have left to do? I used to do this in other distros (ubuntu) pretty fine. Maybe there is something special I need to do/allow in this distro? Do let me know. Any tips and help are appreciated.

I need this for Android App development (college exam), rooting the phone (magisk), flash custom rom (dot os), custom kernel (lazy), etc.

I’ve had issues like this before try another data cable, move the cable around and try to get your PC to see the device (least likely to resolve the issue), or try another USB port.
That’s what I’ve done in the past normally it’s a cable issue however I’ve resolved the problem with one or two the options i stated above. Hope that helps!

3 Likes

In general:

  1. Enable USB debugging in phone
  2. When cable connected, choose Data mode in the USB connection at the phone
  3. When first connect to a computer, choose trust computer at the phone.
2 Likes

@crjackson8812

If there was something wrong with the cable, it would have:

  • The wire couldn’t have charged the phone.
  • The wire which use to work before (for both charging and data transfer), suddenly doesn’t stop working in only one thing (data) but works for another thing (charge). What I mean to say is, both the functionality would have stopped if there was something wrong. Isn’t it.

@sampsonf

So, the number 2 & 3 option of you mentioned (which I already know) doesn’t work.

Thank you guys for trying to help, but it doesn’t really help. Am all ears for any more ideas if there is one. So, far I couldn’t seems to find one.

Did you try the one from the Fedora repos?. Its package name is android-tools.

yes, it is installed. ::

In your example above, you used ./adb devices, which runs the one in your current directory. Just to be sure, you have tried /usr/bin/adb devices and got the same result, right?

I have two adb.

  • One installed by dnf, which runs by default.
  • Another by Android Studio insde /home/pranav/Android/Sdk/platform-tools folder

So far, I have used them both being desperate to see it it works.

Are you using usbguard directly or indirectly (what does systemctl status usbguard.service say?)? Or are you using udev rules to ignore some devices? Or do you have you set something like usbcore.authorized_default=0 to the kernel cmdline? What does less /sys/bus/usb/devices/usbX/authorized_default say for the different USB root devices? (See also here, and here)

If the device is not blocked by configuration (see the paragraph above) I am quite confident to say that it is not the fault of your Linux distro. I ran into this issue quite a lot and in my case it often was the USB cable or port.

Does it really charge or just display that it charges but the battery does not get full? I had the “battery is charging” indication in Android even with broken cables or worn out USB ports. In this case, the smartphone claimed that it would be charged but it did not (or only very slow) and data connection to the phone (via adb or just regular file access) was not possible. Does the cable still work for that? In my case it often depends on the positioning of the cable and the phone, i.e. a loose connection can partially be worked around if you bend it a bit.

pranav@fedora /sys/bus/usb/devices> ls
1-0:1.0  1-1  1-1:1.0  2-0:1.0  2-5  2-5:1.0  2-5:1.1  2-6  2-6:1.0  3-0:1.0  usb1  usb2  usb3
pranav@fedora /sys/bus/usb/devices> cat usb1/authorized_default usb2/authorized_default usb3/authorized_default
1
1
1
pranav@fedora /sys/bus/usb/devices>

Out of three, one of my USB port is damaged. I don’t use that port for connection.

Yes, it does charge. The charging rate is very slow compared to Dash Charger which comes with the phone, but it does charge the phone.

Just double confirmed with my sister’s phone [Samsung Galaxy A70s]. Fedora showed her files normally. All this with the same cable. I wonder why my phone is not showing up. It really got on my nerve to this point.

Some times mobile phones just behalf abnormally.

Last night, my friend show me the “Google 2FA prompt” is not responding. I do not believe it when I hear it. But once verify it in person, yes, on my friend’s phone, only the “back arrow” is working on that prompt screen. The “Yes”, “No” are all not responding.

In your situation, normally I will perform a reset to factory default and try again.

(Some mobile phone can boot to Safe mode. If your phone has that, can try Safe mode first.)

@sampsonf @genodeftest Thanks for reaching out. But after a LOT of research, I think I need to create udev rules in order to use ADB. As mentioned in this post → [Guide] How to Use ADB and Fastboot From Any Directory : Fedora

Really painfully. I wish things were smooth.
I will try to clone that entire repo and do as the post suggests.
I wish I could write a udev for my phone only. There are a whole bunch of phone mentioned inside the rule.

2 Likes

Thanks for the updates.

Good to know connecting Android phones with Linux need udev rules …

This rule should be installed into /etc/udev/rules.d/51-android.rules on your computer. If it is not, you can create a symlink from /usr/share/doc/android-tools/51-android.rules.

Please note that the 51-android.rules shipped with Fedora 34 has a bug which has been fixed upstream (but the update/latest version cannot be installed in Fedora 34 because android-tools fails to compile for Fedora 34).

Or does this 51-android.rules file not contain your smartphone?

I see a bunch of rules in /lib/udev/rules.d folder. But not a single rule inside /etc/udev/rules.d folder. So, there is no 51-android.rules file in Fedora 34.

Unless if this counts:

pranav@fedora ~> locate 51-android.rules
/usr/share/doc/android-tools/51-android.rules
pranav@fedora ~> cd /usr/share/doc/android-tools/
pranav@fedora /usr/share/doc/android-tools> ls
51-android.rules  NOTICE  OVERVIEW.TXT  protocol.txt  SERVICES.TXT
pranav@fedora /usr/share/doc/android-tools>

I think we are reaching somewhere. Please do replay.

1 Like
$ locate 51-android.rules
/etc/udev/rules.d/51-android.rules
/usr/share/doc/android-tools/51-android.rules

The first file is a symlink to the second one.

Can you try creating the file, e.g. via symlink? Example (as root):

ln --symbolic /usr/share/doc/android-tools/51-android.rules /etc/udev/rules.d/51-android.rules

I don’t know what’s needed to apply that rule so it may be necessary to systemctl daemon-reload or systemctl restart systemd-udevd.service.

1 Like

Thanks for the update!

I did what you said. (Thank you. I really think, this time we will get somewhere).
Since there was no attribute/value mentioning about Oneplus 5, I modified 51-android.rules with these two lines:

pranav@fedora ~> cat /etc/udev/rules.d/51-android.rules | grep -A2 -i oneplus
#Oneplus
SUBSYSTEM=="usb", ATTR{idVendor}=="2a70", TAG+="systemd", ENV{SYSTEMD_WANTS}="adb.service"

I got the attribute from an article. Problem is, they’re still something we need to do because ADB command doesn’t recognize the phone, neither the phone recognizes pc. They are doing their best to not talk with each other. But I will make them.

As long as the device is not in lsusb's output, adb will be unable to find it, so this is where we should start imho.

The fact that it is not in lsusb's output may be a result of one of (or a combination of):

  • a configuration issue on the PC (we ruled out authorized_default and usbguard already, but there may be more I don’t know of)
  • a hardware issue (it seems like you tried different ports, cables and devices already)
  • a configuration issue on the Oneplus (from what you wrote above, we can probably rule that out)

I’m almost out of ideas, but maybe someone else can help.

One last idea:
After a fresh reboot, can you please attach the smartphone and then get the output of journalctl -k? If you search for usb, error, warning, failed or similar, does it show something which may be related to this issue?

Let me know what you can see in this log. I attached my phone to the laptop and shut down the distro and power on the distro using the power button.

pranav@fedora ~> journalctl -k | grep -i -e usb -e error -e warning -e failed
Jun 12 15:16:56 fedora kernel: ACPI: bus type USB registered
Jun 12 15:16:56 fedora kernel: usbcore: registered new interface driver usbfs
Jun 12 15:16:56 fedora kernel: usbcore: registered new interface driver hub
Jun 12 15:16:56 fedora kernel: usbcore: registered new device driver usb
Jun 12 15:16:56 fedora kernel: pci 0000:00:1d.0: quirk_usb_early_handoff+0x0/0x6d0 took 12377 usecs
Jun 12 15:16:56 fedora kernel: ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
Jun 12 15:16:56 fedora kernel: ehci-pci 0000:00:1d.0: new USB bus registered, assigned bus number 1
Jun 12 15:16:56 fedora kernel: ehci-pci 0000:00:1d.0: USB 2.0 started, EHCI 1.00
Jun 12 15:16:56 fedora kernel: usb usb1: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 5.12
Jun 12 15:16:56 fedora kernel: usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
Jun 12 15:16:56 fedora kernel: usb usb1: Product: EHCI Host Controller
Jun 12 15:16:56 fedora kernel: usb usb1: Manufacturer: Linux 5.12.9-300.fc34.x86_64 ehci_hcd
Jun 12 15:16:56 fedora kernel: usb usb1: SerialNumber: 0000:00:1d.0
Jun 12 15:16:56 fedora kernel: hub 1-0:1.0: USB hub found
Jun 12 15:16:56 fedora kernel: ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
Jun 12 15:16:56 fedora kernel: uhci_hcd: USB Universal Host Controller Interface driver
Jun 12 15:16:56 fedora kernel: xhci_hcd 0000:00:14.0: new USB bus registered, assigned bus number 2
Jun 12 15:16:56 fedora kernel: usb usb2: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 5.12
Jun 12 15:16:56 fedora kernel: usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1
Jun 12 15:16:56 fedora kernel: usb usb2: Product: xHCI Host Controller
Jun 12 15:16:56 fedora kernel: usb usb2: Manufacturer: Linux 5.12.9-300.fc34.x86_64 xhci-hcd
Jun 12 15:16:56 fedora kernel: usb usb2: SerialNumber: 0000:00:14.0
Jun 12 15:16:56 fedora kernel: hub 2-0:1.0: USB hub found
Jun 12 15:16:56 fedora kernel: xhci_hcd 0000:00:14.0: new USB bus registered, assigned bus number 3
Jun 12 15:16:56 fedora kernel: xhci_hcd 0000:00:14.0: Host supports USB 3.0 SuperSpeed
Jun 12 15:16:56 fedora kernel: usb usb3: New USB device found, idVendor=1d6b, idProduct=0003, bcdDevice= 5.12
Jun 12 15:16:56 fedora kernel: usb usb3: New USB device strings: Mfr=3, Product=2, SerialNumber=1
Jun 12 15:16:56 fedora kernel: usb usb3: Product: xHCI Host Controller
Jun 12 15:16:56 fedora kernel: usb usb3: Manufacturer: Linux 5.12.9-300.fc34.x86_64 xhci-hcd
Jun 12 15:16:56 fedora kernel: usb usb3: SerialNumber: 0000:00:14.0
Jun 12 15:16:56 fedora kernel: hub 3-0:1.0: USB hub found
Jun 12 15:16:56 fedora kernel: usb: port power management may be unreliable
Jun 12 15:16:56 fedora kernel: usbcore: registered new interface driver usbserial_generic
Jun 12 15:16:56 fedora kernel: usbserial: USB Serial support registered for generic
Jun 12 15:16:56 fedora kernel: usbcore: registered new interface driver usbhid
Jun 12 15:16:56 fedora kernel: usbhid: USB HID core driver
Jun 12 15:16:56 fedora kernel: RAS: Correctable Errors collector initialized.
Jun 12 15:16:56 fedora kernel: usb 1-1: new high-speed USB device number 2 using ehci-pci
Jun 12 15:16:56 fedora kernel: usb 2-5: new full-speed USB device number 2 using xhci_hcd
Jun 12 15:16:56 fedora kernel: usb 2-5: New USB device found, idVendor=8087, idProduct=07dc, bcdDevice= 0.01
Jun 12 15:16:56 fedora kernel: usb 2-5: New USB device strings: Mfr=0, Product=0, SerialNumber=0
Jun 12 15:16:56 fedora kernel: usb 1-1: New USB device found, idVendor=8087, idProduct=8001, bcdDevice= 0.03
Jun 12 15:16:56 fedora kernel: usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
Jun 12 15:16:56 fedora kernel: hub 1-1:1.0: USB hub found
Jun 12 15:16:56 fedora kernel: usb 2-6: new full-speed USB device number 3 using xhci_hcd
Jun 12 15:16:56 fedora kernel: usb 2-6: New USB device found, idVendor=04f3, idProduct=2012, bcdDevice=11.12
Jun 12 15:16:56 fedora kernel: usb 2-6: New USB device strings: Mfr=4, Product=14, SerialNumber=0
Jun 12 15:16:56 fedora kernel: usb 2-6: Product: Touchscreen
Jun 12 15:16:56 fedora kernel: usb 2-6: Manufacturer: ELAN
Jun 12 15:16:56 fedora kernel: input: ELAN Touchscreen as /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.0/0003:04F3:2012.0001/input/input7
Jun 12 15:16:56 fedora kernel: input: ELAN Touchscreen as /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.0/0003:04F3:2012.0001/input/input8
Jun 12 15:16:56 fedora kernel: input: ELAN Touchscreen as /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.0/0003:04F3:2012.0001/input/input9
Jun 12 15:16:56 fedora kernel: hid-generic 0003:04F3:2012.0001: input,hiddev96,hidraw0: USB HID v1.10 Device [ELAN Touchscreen] on usb-0000:00:14.0-6/input0
Jun 12 15:16:56 fedora kernel: usb 1-1-port7: over-current condition
Jun 12 15:16:56 fedora kernel: usb usb2-port7: over-current condition
Jun 12 15:16:56 fedora kernel: usb usb2-port8: over-current condition
Jun 12 15:16:56 fedora kernel: usb 1-1-port8: over-current condition
Jun 12 15:16:56 fedora kernel: input: ELAN Touchscreen as /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.0/0003:04F3:2012.0001/input/input11
Jun 12 15:16:56 fedora kernel: input: ELAN Touchscreen UNKNOWN as /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.0/0003:04F3:2012.0001/input/input12
Jun 12 15:16:56 fedora kernel: input: ELAN Touchscreen UNKNOWN as /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.0/0003:04F3:2012.0001/input/input13
Jun 12 15:16:56 fedora kernel: hid-multitouch 0003:04F3:2012.0001: input,hiddev96,hidraw0: USB HID v1.10 Device [ELAN Touchscreen] on usb-0000:00:14.0-6/input0
Jun 12 15:17:00 fedora kernel: usbcore: registered new interface driver btusb
Jun 12 15:17:01 fedora kernel: psmouse serio1: Failed to enable mouse on isa0060/serio1