I’ve tried to use adb in a toolbox container (just install it via dnf install android-tools etc. inside of the container), but it seems it is too isolated from the host, because while it can detect a device, it cannot get a permission. Even in Android’s recovery and with sudo in the container it only shows this:
$ sudo adb devices
List of devices attached
* daemon not running; starting now at tcp:5037
* daemon started successfully
4e1d2a26 no permissions; see [http://developer.android.com/tools/device.html]
So should I just give up and layer it on the host instead, or (how) can I make it work inside of the container?
Been trying to get fastboot and adb working in a toolbox and getting “no permissions” errors … until I saw this. Both now working, even without sudo, thanks! @pluto
For what it’s worth, the android-tools package in Fedora is extremely old (from 2018-08-28) and can cause issues with some phones.
(For example: My old, problematic Nexus 6P doesn’t work fully with fastboot due to the ancient android-tools, when it tries to call mke2fs… but adb still seems generally fine to use, even in the old version Fedora ships.)
Kind of off-topic: Is it safe if I use the package from Fedora repos and not the Google zip? I have a relatively old phone, which is released 6-7 years ago.
The Nexus 6P, the phone I mentioned above, is nearly 5 years old and has this problem. I was trying to installer newer version of Android (custom ROMs) and also UBports on it, and that’s where I hit the problem with way-too-old android-tools in Fedora.
So, if you’re sticking with stock ROMs (that are extremely out of date at this point), it might be fine. If you want to use something that has been updated in the past few years (and you really should, if you’re actually going to use the device… due to huge security issues in older versions of Android), you might hit the issue when reformatting some filesystems on the device (which is standard on installation of basically any new ROM or Linux-based OS).
I also flash custom ROMs on a Xiami Mi 4 and didn’t have any problem so far. I didn’t try to reformat via adb though, I do reformatting via recovery. Adb commands I use so far are push, pull, sideload, remount and shell. I really don’t want to use anything which is compiled and packaged by Google.
In case you’re trying to decide whether or not to trust this third-party repository from “M0Rf30”, know that it is the upstream source for the android-sdk-platform-tools-common Ubuntu package. See here and here.
DIY approach
You can also run lsusb while the device is plugged in, locate and copy its vendor code and write your own rule for it at /etc/udev/rules.d/51-android.rules:
# Skip if not connected via USB
SUBSYSTEM!="usb", GOTO="android_usb_rules_end"
LABEL="android_usb_rules_begin"
# Here you replace "18d1" (Google vendor code) with your device's vendor code
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ENV{adb_user}="yes"
# Enable device as a user device if found
ENV{adb_user}=="yes", MODE="0660", GROUP="adbusers", TAG+="uaccess"
LABEL="android_usb_rules_end"
Then you create the group adbusers and add yourself to it. After a reboot adb devices should recognize the device.