ADB cannot connect to daemon解决方案(adb server version (41) doesn't match this client (40))

 最近更新到Android Studio3.5 使用adb wifi连接的时候出现以下问题无法连接到设备:

* daemon not running; starting now at tcp:5037
ADB server didn't ACK
Full server startup log: /var/folders/df/3drfx_117t1g7d97fxd86j_w0000gn/T//adb.501.log
Server had pid: 14447
--- adb starting (pid 14447) ---
adb I 10-30 20:55:57 14447 194321 main.cpp:57] Android Debug Bridge version 1.0.39
adb I 10-30 20:55:57 14447 194321 main.cpp:57] Version 0.0.1-4500957
adb I 10-30 20:55:57 14447 194321 main.cpp:57] Installed as /Users/praveen/Library/Android/sdk/platform-tools/adb
adb I 10-30 20:55:57 14447 194321 main.cpp:57] 
adb I 10-30 20:55:57 14445 194315 adb_auth_host.cpp:416] adb_auth_init...
adb I 10-30 20:55:57 14445 194315 adb_auth_host.cpp:174] read_key_file '/Users/praveen/.android/adbkey'...
error: could not install *smartsocket* listener: Address already in use

* failed to start daemon
error: cannot connect to daemon

原因是系统里有多个版本的adb.

运行which adb

$ which adb
/usr/bin/adb

发现情况是在terminal直接输入adb命令默认运行/user/bin/adb,因为android studio开启时会自启adb,/usr/bin/adb与platform-tools的版本不一致导致无法运行,而在platform-tools目录下运行./adb命令正常.

解决方法

adb kill-server
sudo cp ~/Android/Sdk/platform-tools/adb /usr/bin/adb
sudo chmod +x /usr/bin/adb
adb start-server

 

你可能感兴趣的:(Linux)