尝试运行 fastboot 命令时,我的 Ubuntu 机器上出现了一个非常奇怪的问题。
当我运行时:
fastboot devices
我明白了
no permissions fastboot
所以我以管理员权限运行命令:
sudo fastboot devices
然后我得到结果
sudo: fastboot: command not found
这怎么可能?我的 PATH 中有该目录,无需 sudo 一切正常。
最佳答案
无需在每次需要运行 fastboot
时通过 sudo
强制授予权限,您可以永久修复该问题:
- 使用
lsusb
识别您的设备 USB VendorID - 配置
udev
以在设备插入时设置适当的权限 - 利润!
作为奖励 - 它也将针对 adb
进行修复。
例如,在我的例子中(对于“Megafon SP-A20i”):
$ fastboot devices
no permissions fastboot
$ sudo fastboot devices
[sudo] password for kaa:
MedfieldA9055F28 fastboot
$
让我们修复:
首先,我们需要识别设备:
a) 查找 usb 总线编号(hack:我知道该设备是基于 Intel 的)
$ fastboot -l devices
no permissions fastboot usb:1-1.2
$ lsusb |grep 001 |grep -i intel
Bus 001 Device 044: ID 8087:09ef Intel Corp.
Bus 001 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
$
b) 寻找其他英特尔设备:
$ lsusb |grep 8087
Bus 002 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 044: ID 8087:09ef Intel Corp.
Bus 001 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
$
集线器绝对不是智能手机,所以 - 我们需要的 USB vendorID 是“8087”。
其次,配置 udev
(您必须将“idVendor”值替换为您的值):
$ sudo sh -c "echo '# Megafon SP-A20i' >> /etc/udev/rules.d/51-android.rules"
$ sudo sh -c "echo 'SUBSYSTEM==\"usb\", ATTR{idVendor}==\"8087\", MODE=\"0666\", GROUP=\"plugdev\"' >> /etc/udev/rules.d/51-android.rules"
$ sudo service udev restart
udev stop/waiting
udev start/running, process 1821
$
第三,重新插入你的设备,让 udev
发挥它的魔力。
最终检查:
$ fastboot -l devices
MedfieldA9055F28 fastboot usb:1-1.2
$ adb devices
List of devices attached
$ fastboot reboot
rebooting...
finished. total time: 0.253s
$ sleep 90
$ adb devices
List of devices attached
MedfieldA9055F28 device
$
瞧!
关于android - fastboot 和 adb 不能与 sudo 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27017453/