赞
踩
首先说现象,很简单,就是使用桌面环境时,运行scrcpy提示找不到设备,尝试后发现可以通过adb kill-server && adb start-server命令解决该问题,但是机器重启后又会出现该问题,经尝试后发现,多半是权限问题,在普通用户下执行该命令出现结果如下:
test@test:~ $scrcpy
scrcpy 2.3.1 <https://github.com/Genymobile/scrcpy>
* daemon not running; starting now at tcp:5037
* daemon started successfully
ERROR: Could not find any ADB device
ERROR: Server connection failed
test@test:~ $adb start-server
* daemon not running; starting now at tcp:5037
* daemon started successfully
test@test:~ $adb devices
List of devices attached
可见普通用户启动adb服务会导致无法连接,知道这个就好解决了,首先切换到root用户,执行同样的命令(如果之前已经在普通用户下运行过adb相关命令,则要先执行adb kill-server,否则启动时会提示端口被占用),结果如下:
test@test:~ $su root
密码:
root@test:/home/test $adb kill-server
root@test:/home/test $adb start-server
* daemon not running; starting now at tcp:5037
* daemon started successfully
root@test:/home/test $adb devices
List of devices attached
b2d21f9b device
root@test:/home/test $exit
exit
test@test:~ $adb devices
List of devices attached
b2d21f9b device
此时普通用户也可运行adb相关命令,如果嫌麻烦可以将adb start-server命令加入开机启动脚本,就不用每次开机都去手动切换root用户去启动了
当然,除了切换root用户外,还可以通过sudo提权来运行db start-server,效果是一样的
test@test:~ $sudo adb start-server
[sudo] test 的密码:
* daemon not running; starting now at tcp:5037
* daemon started successfully
test@test:~ $adb devices
List of devices attached
b2d21f9b device
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。