Ubuntu下运行adb devices找不到设备的问题

问题描述

Windows下安装Android studio,里面含有Android SDK,自动包含了adb在内的很多工具包;因开发需要,在WSL中安装了Ubuntu,分别是18和22的,其中也分别安装了Android SDK,官网下载,可以运行adb命令。

本来在Windows下和Ubuntu下都可以直接使用,但是今天上来在Ubuntu下突然找不到设备了,运行adb devices,显示:

shell 复制代码
List of devices attached
adb server version (41) doesn't match this client (39); killing...
* daemon started successfully

再次运行命令,依旧是空列表:

shell 复制代码
List of devices attached

问题原因

执行一些简单操作:

shell 复制代码
adb kill-server
adb start-server

* daemon not running; starting now at tcp:5037
* daemon started successfully

依旧找不到:

shell 复制代码
List of devices attached

在Windows下试一下:

shell 复制代码
adb server version (39) doesn't match this client (41); killing...
* daemon started successfully
List of devices attached
c731111d        device

发现虽然也有不匹配的问题,但是是可以找到设备的。

有趣的是,这2个地方adb server,adb client的相反的,逛了一下Stackoverflow,可能是版本的问题。在Windows下和Ubuntu下的adb版本不同。

问题解决

Windows下运行:

shell 复制代码
C:\Users\xxx\AppData\Local\Android\Sdk\platform-tools\adb --version

显示:

shell 复制代码
Android Debug Bridge version 1.0.41
Version 34.0.4-10411341
Installed as C:\Users\xxx\AppData\Local\Android\Sdk\platform-tools\adb.exe
Running on Windows 10.0.18363

Ubuntu下运行:

shell 复制代码
adb --version

显示:

shell 复制代码
Android Debug Bridge version 1.0.39
Version 1:8.1.0+r23-5~18.04
Installed as /usr/lib/android-sdk/platform-tools/adb

先把Windows的让他不起作用(重命名或者移出环境),在Ubuntu下接着尝试,发现

shell 复制代码
$ adb start-server

adb server version (41) doesn't match this client (39); killing...
ADB server didn't ACK
Full server startup log: /tmp/adb.1000.log
Server had pid: 16935
--- adb starting (pid 16935) ---
adb I 09-21 14:38:17 16935 16935 main.cpp:57] Android Debug Bridge version 1.0.39
adb I 09-21 14:38:17 16935 16935 main.cpp:57] Version 1:8.1.0+r23-5~18.04
adb I 09-21 14:38:17 16935 16935 main.cpp:57] Installed as /usr/lib/android-sdk/platform-tools/adb
adb I 09-21 14:38:17 16935 16935 main.cpp:57] 
adb I 09-21 14:38:17 16935 16935 adb_auth_host.cpp:416] adb_auth_init...
adb I 09-21 14:38:17 16935 16935 adb_auth_host.cpp:174] read_key_file '/home/xxx/.android/adbkey'...
adb I 09-21 14:38:17 16935 16935 adb_auth_host.cpp:391] adb_auth_inotify_init...
adb server killed by remote request

* failed to start daemon
error: cannot connect to daemon

没有启动成功,而这里报的错误是adb所在路径并不是我们所安装的路径【那是什么时候安装的呢?】,我们所安装的只有在自己当时下载解压的位置,检查版本:

shell 复制代码
~/tools/platform-tools/adb --version

结果:

shell 复制代码
Android Debug Bridge version 1.0.41
Version 34.0.4-10411341
Installed as /home/gy/tools/platform-tools/adb
Running on Linux 4.4.0-18362-Microsoft (x86_64)

这个才是我们需要的,版本也是正确的

参考资料

相关推荐
打不了嗝 ᥬ᭄23 分钟前
Linux的权限
linux
落幕28 分钟前
C语言-进程
linux·运维·服务器
深度Linux37 分钟前
C++程序员内功修炼——Linux C/C++编程技术汇总
linux·项目实战·c/c++
风静如云2 小时前
OpenBMC:BmcWeb定义service
linux
leoufung3 小时前
VIM FZF 安裝和使用
linux·编辑器·vim
bugtraq20213 小时前
XiaoMi Mi5(gemini) 刷入Ubuntu Touch 16.04——安卓手机刷入Linux
linux·运维·ubuntu
CodeWithMe4 小时前
[ Vim ] 常用命令 and 配置
linux·编辑器·vim
DC_BLOG4 小时前
Linux-GlusterFS进阶分布式卷
linux·运维·服务器·分布式
cookies_s_s5 小时前
Linux--进程(进程虚拟地址空间、页表、进程控制、实现简易shell)
linux·运维·服务器·数据结构·c++·算法·哈希算法
丁劲犇5 小时前
碳基生物的悲歌-DeepSeek思考实现Linux动态库递归收集工具
linux·递归·deepseek·ldd