adb shell提示error: could not install *smartsocket* listener

本文介绍了解决ADB命令中因5037端口被占用而导致的问题,通过查找占用端口的进程并终止该进程来解决ADB连接失败的情况。

执行adb shell命令遇到错误提示:

C:\Users\tester>adb shell ps|grep demo
error: could not install *smartsocket* listener: cannot bind to 127.0.0.1:5037: 通常每个套接字地址(协议/网络地址/端口)只
允许使用一次。 (10048)
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
could not read ok from ADB Server
* failed to start daemon *
error: cannot connect to daemon

看提示是端口被占用,检查步骤:

C:\Users\tester>netstat -aon|findstr "5037"
  TCP    127.0.0.1:5037         0.0.0.0:0              LISTENING       5148
  TCP    127.0.0.1:5037         127.0.0.1:54801        ESTABLISHED     5148
  TCP    127.0.0.1:5037         127.0.0.1:54931        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:54975        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:54992        TIME_WAIT       0
  TCP    127.0.0.1:51966        127.0.0.1:5037         TIME_WAIT       0
  TCP    127.0.0.1:51967        127.0.0.1:5037         TIME_WAIT       0
  TCP    127.0.0.1:51968        127.0.0.1:5037         TIME_WAIT       0
  TCP    127.0.0.1:51969        127.0.0.1:5037         TIME_WAIT       0

找到了5037端口占用的PID “5148”,再执行命令:

C:\Users\tester>tasklist|findstr "5148"
360MobileLink.exe             5148 Console                    1     24,424 K

找到罪魁祸首了,kill它就可以了。

注意可能需要重新授权,不然会提示:

C:\Users\tester>adb shell ps|grep demo
error: device unauthorized.
This adb server's $ADB_VENDOR_KEYS is not set
Try 'adb kill-server' if that seems wrong.
Otherwise check for a confirmation dialog on your device.



[info] [Appium] Welcome to Appium v1.20.2 [info] [Appium] Non-default server args: [info] [Appium] relaxedSecurityEnabled: true [info] [Appium] allowInsecure: { [info] [Appium] } [info] [Appium] denyInsecure: { [info] [Appium] } [info] [Appium] Appium REST http interface listener started on 0.0.0.0:4723[info] [HTTP] --> GET /wd/hub/sessions [info] [HTTP] {} [debug] [GENERIC] Calling AppiumDriver.getSessions() with args: [] [debug] [GENERIC] Responding to client with driver.getSessions() result: [] [info] [HTTP] <-- GET /wd/hub/sessions 200 5 ms - 40 [info] [HTTP] [info] [HTTP] --> POST /wd/hub/session [info] [HTTP] {"desiredCapabilities":{"platformName\"":"Android","newCommandTimeout":0,"connectHardwareKeyboard":true}} [debug] [MJSONWP] Calling AppiumDriver.createSession() with args: [{"platformName\"":"Android","newCommandTimeout":0,"connectHardwareKeyboard":true},null,null] [debug] [BaseDriver] Event 'newSessionRequested' logged at 1750921438941 (15:03:58 GMT+0800 (中国标准时间)) [debug] [BaseDriver] Event 'newSessionStarted' logged at 1750921438942 (15:03:58 GMT+0800 (中国标准时间)) [debug] [MJSONWP] Encountered internal error running command: Error: You must include a platformName capability [debug] [MJSONWP] at AppiumDriver.getDriverAndVersionForCaps (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\lib\appium.js:216:13) [debug] [MJSONWP] at AppiumDriver.createSession (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\lib\appium.js:324:66) [debug] [MJSONWP] at commandExecutor (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\appium-base-driver\lib\basedriver\driver.js:334:9) [debug] [MJSONWP] at AppiumDriver.executeCommand (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\appium-base-driver\lib\basedriver\driver.js:348:15) [debug] [MJSONWP] at AppiumDriver.executeCommand (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\lib\appium.js:533:26) [debug] [MJSONWP] at asyncHandler (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\appium-base-driver\lib\protocol\protocol.js:297:34) [debug] [MJSONWP] at D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\appium-base-driver\lib\protocol\protocol.js:423:15 [debug] [MJSONWP] at Layer.handle [as handle_request] (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\express\lib\router\layer.js:95:5) [debug] [MJSONWP] at next (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\express\lib\router\route.js:137:13) [debug] [MJSONWP] at Route.dispatch (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\express\lib\router\route.js:112:3) [debug] [MJSONWP] at Layer.handle [as handle_request] (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\express\lib\router\layer.js:95:5) [debug] [MJSONWP] at D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\express\lib\router\index.js:281:22 [debug] [MJSONWP] at Function.process_params (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\express\lib\router\index.js:335:12) [debug] [MJSONWP] at next (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\express\lib\router\index.js:275:10) [debug] [MJSONWP] at logger (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\morgan\index.js:144:5) [debug] [MJSONWP] at Layer.handle [as handle_request] (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\express\lib\router\layer.js:95:5) [debug] [MJSONWP] at trim_prefix (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\express\lib\router\index.js:317:13) [debug] [MJSONWP] at D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\express\lib\router\index.js:284:7 [debug] [MJSONWP] at Function.process_params (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\express\lib\router\index.js:335:12) [debug] [MJSONWP] at next (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\express\lib\router\index.js:275:10) [debug] [MJSONWP] at D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\body-parser\lib\read.js:130:5 [debug] [MJSONWP] at invokeCallback (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\raw-body\index.js:224:16) [debug] [MJSONWP] at done (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\raw-body\index.js:213:7) [debug] [MJSONWP] at IncomingMessage.onEnd (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\raw-body\index.js:273:7) [debug] [MJSONWP] at IncomingMessage.emit (events.js:208:15) [debug] [MJSONWP] at endReadableNT (_stream_readable.js:1168:12) [debug] [MJSONWP] at processTicksAndRejections (internal/process/task_queues.js:77:11) [info] [HTTP] <-- POST /wd/hub/session 500 27 ms - 179 [info] [HTTP]  [info] [HTTP] --> DELETE /wd/hub/session [info] [HTTP] {} [debug] [HTTP] No route found for /wd/hub/session [info] [HTTP] <-- DELETE /wd/hub/session 404 5 ms - 211 [info] [HTTP] [info] [HTTP] --> POST /wd/hub/session [info] [HTTP] {"desiredCapabilities":{"ensureWebviewsHavePages":true,"platformName":"Android","newCommandTimeout":0,"connectHardwareKeyboard":true}} [debug] [MJSONWP] Calling AppiumDriver.createSession() with args: [{"ensureWebviewsHavePages":true,"platformName":"Android","newCommandTimeout":0,"connectHardwareKeyboard":true},null,null] [debug] [BaseDriver] Event 'newSessionRequested' logged at 1750921458583 (15:04:18 GMT+0800 (中国标准时间)) [warn] [Appium] [warn] [Appium] ====================================================================== [warn] [Appium] DEPRECATION WARNING: [warn] [Appium] [warn] [Appium] The 'automationName' capability was not provided in the desired [warn] [Appium] capabilities for this Android session [warn] [Appium] [warn] [Appium] Setting 'automationName=UiAutomator2' by default and using the [warn] [Appium] UiAutomator2 Driver [warn] [Appium] [warn] [Appium] The next major version of Appium (2.x) will **require** the [warn] [Appium] 'automationName' capability to be set for all sessions on all [warn] [Appium] platforms [warn] [Appium] [warn] [Appium] In previous versions (Appium <= 1.13.x), the default was [warn] [Appium] 'automationName=UiAutomator1' [warn] [Appium] [warn] [Appium] If you wish to use that automation instead of UiAutomator2, please [warn] [Appium] add 'automationName=UiAutomator1' to your desired capabilities [warn] [Appium] [warn] [Appium] For more information about drivers, please visit [warn] [Appium] http://appium.io/docs/en/about-appium/intro/ and explore the [warn] [Appium] 'Drivers' menu [warn] [Appium] [warn] [Appium] ====================================================================== [warn] [Appium] [info] [Appium] Appium v1.20.2 creating new AndroidUiautomator2Driver (v1.61.2) session [info] [Appium] Applying relaxed security to 'AndroidUiautomator2Driver' as per server command line argument. All insecure features will be enabled unless explicitly disabled by --deny-insecure [debug] [BaseDriver] Creating session with MJSONWP desired capabilities: { [debug] [BaseDriver] "ensureWebviewsHavePages": true, [debug] [BaseDriver] "platformName": "Android", [debug] [BaseDriver] "newCommandTimeout": 0, [debug] [BaseDriver] "connectHardwareKeyboard": true [debug] [BaseDriver] } [warn] [BaseDriver] The following capabilities were provided, but are not recognized by Appium: [warn] [BaseDriver] connectHardwareKeyboard [info] [BaseDriver] Session created with session id: a7def776-063b-41be-b908-d8c598571316 [info] [UiAutomator2] Neither 'app' nor 'appPackage' was set. Starting UiAutomator2 without the target application[debug] [UiAutomator2] Deleting UiAutomator2 session [debug] [BaseDriver] Event 'newSessionStarted' logged at 1750921458808 (15:04:18 GMT+0800 (中国标准时间)) [debug] [MJSONWP] Encountered internal error running command: Error: Could not find 'adb.exe' in ["D:\\android-sdk-windows\\platform-tools\\adb.exe","D:\\android-sdk-windows\\emulator\\adb.exe","D:\\android-sdk-windows\\cmdline-tools\\latest\\bin\\adb.exe","D:\\android-sdk-windows\\tools\\adb.exe","D:\\android-sdk-windows\\tools\\bin\\adb.exe","D:\\android-sdk-windows\\adb.exe"]. Do you have Android Build Tools installed at 'D:\android-sdk-windows'? [debug] [MJSONWP] at ADB.getBinaryFromSdkRoot (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\appium-adb\lib\tools\system-calls.js:125:11) [debug] [MJSONWP] at ADB.getSdkBinaryPath (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\appium-adb\lib\tools\system-calls.js:44:10) [debug] [MJSONWP] at ADB.getAdbWithCorrectAdbPath (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\appium-adb\lib\tools\adb-commands.js:89:26) [debug] [MJSONWP] at Function.createADB (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\appium-adb\lib\adb.js:56:3) [debug] [MJSONWP] at Object.createBaseADB (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\appium-android-driver\lib\android-helpers.js:108:10) [debug] [MJSONWP] at Object.getDeviceInfoFromCaps (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\appium-android-driver\lib\android-helpers.js:193:15) [debug] [MJSONWP] at AndroidUiautomator2Driver.startUiAutomator2Session (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\appium-uiautomator2-driver\lib\driver.js:327:26) [debug] [MJSONWP] at AndroidUiautomator2Driver.createSession (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\appium-uiautomator2-driver\lib\driver.js:224:7) [debug] [MJSONWP] at AppiumDriver.createSession (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\lib\appium.js:371:35) [info] [HTTP] <-- POST /wd/hub/session 500 258 ms - 574 [info] [HTTP]  [info] [HTTP] --> DELETE /wd/hub/session [info] [HTTP] {} [debug] [HTTP] No route found for /wd/hub/session [info] [HTTP] <-- DELETE /wd/hub/session 404 0 ms - 211 [info] [HTTP] 
06-27
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值