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)

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

参考资料

相关推荐
愚戏师1 小时前
Linux复习笔记(六)shell编程
linux·笔记·shell
大胆飞猪2 小时前
Linux操作系统--进程间通信(system V共享内存)
linux
LunarCod2 小时前
Ubuntu使用Docker搭建SonarQube企业版(含破解方法)
linux·运维·服务器·ubuntu·docker·开源·sonarqube
betazhou2 小时前
基于Linux环境实现Oracle goldengate远程抽取MySQL同步数据到MySQL
linux·数据库·mysql·oracle·ogg
什么半岛铁盒2 小时前
Linux信号的保存
linux·运维·网络
百锦再2 小时前
大数据技术的主要方向及其应用详解
大数据·linux·网络·python·django·pygame
2301_803554522 小时前
vim,gcc/g++,makefile,cmake
linux·编辑器·vim
惜.己3 小时前
Linux常用命令(十四)
linux·运维·服务器
linkingvision4 小时前
H5S 视频监控AWS S3 对象存储
linux·运维·aws·视频监控s3对象存储
初次见面我叫泰隆4 小时前
MySQL——1、数据库基础
数据库·adb