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)

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

参考资料

相关推荐
try2find29 分钟前
移动conda虚拟环境的安装目录
linux·运维·conda
笑衬人心。31 分钟前
Ubuntu 22.04 修改默认 Python 版本为 Python3 笔记
笔记·python·ubuntu
码农101号1 小时前
Linux中容器文件操作和数据卷使用以及目录挂载
linux·运维·服务器
PanZonghui1 小时前
Centos项目部署之Nginx 的安装与卸载
linux·nginx
ladymorgana1 小时前
【docker】修改 MySQL 密码后 Navicat 仍能用原密码连接
mysql·adb·docker
PanZonghui1 小时前
Centos项目部署之安装数据库MySQL8
linux·后端·mysql
PanZonghui1 小时前
Centos项目部署之运行SpringBoot打包后的jar文件
linux·spring boot
PanZonghui1 小时前
Centos项目部署之Java安装与配置
java·linux
程序员弘羽1 小时前
Linux进程管理:从基础到实战
linux·运维·服务器
PanZonghui2 小时前
Centos项目部署之常用操作命令
linux