【Android测试】adb shell回车后出现 error closed的解决办法

本文针对在手机连接USB进行Monkey测试或eclipse调试时出现的adb异常问题,提供了四种有效的解决方法,包括重启电脑、操作手机USB调试开关、重启手机及使用adb命令等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

现象1:在手机连接USB进行Monkey测试的过程中,再启动一个CMD窗口输入,adb shell回车后出现 error closed的的现象。某些情况下,一些手机会出现此现象。

现象2:在手机连接USB进行eclipse调试或安装App时,eclispe控制台提示:Failed to install ***.apk on device '019417a3': Unable to open sync connection!

个人认为两种现象的原因是一样的。

解决办法如下:

第一种:重启电脑,之后把手机查到电脑上,启动eclipse

第二种:手机-设置-应用程序-开发-usb调试打开再关闭一次

第三种:重启手机,usb调试打开再关闭一次。

第四种:在cmd下Try "adb kill-server" and then "adb start-server"。

个人认为,第二种,第三种方法更为实用



转载于:https://my.oschina.net/u/199776/blog/330604

测试项目: API使能与关闭ADB 测试步骤: 1.调用fibo_device_setusb_composition(25,0)关闭ADB 2.重启模组,adb devices查询ADB 3.adb shell进模块 4.从串口进入,并调用fibo_device_setusb_composition(25,1)使能ADB 5.重启模组,adb devices查询ADB 6.adb shell进模块 7.调用fibo_device_setusb_composition(24,1)切换ECM模式 8.reboot重启后检查端口枚举 9.调用fibo_device_setusb_composition(24,0)关闭ADB 10.重启模组,adb devices查询ADB 11.adb shell进模块 12.从串口进入,并调用fibo_device_setusb_composition(24,1)使能ADB 13.重启模组,adb devices查询ADB 14.adb shell进模块 15.调用fibo_device_setusb_composition(e_fibo_usb_mode_state_ex_t type, int adb_enable) 接口,配置 int adb_enable为除1、0以外的参数 预期结果: 1.ADB关闭配置成功 2.重启成功,识别不到device id 3.adb shell不能进入模块 4.ADB开启配置成功 5.重启成功,识别到device id 6.adb shell能进入模块 7.切换USB成功 8.重启成功,DIAG+ECM+QDSS+DPL+AT+NMEA+ADB端口枚举成功 9.ADB关闭配置成功 10.重启成功,识别不到device id 11.adb shell不能进入模块 12.ADB开启配置成功 13.重启成功,识别到device id 14.adb shell能进入模块 15.配置失败,返回参数错误 日志输出: [###info####] [2025-08-10 11:10:50] [adb -s 958db3d9 wait-for-device shell root] adb is already running as root [###info####] [2025-08-10 11:10:51] [adb -s 958db3d9 wait-for-device shell] Enter root Passwd:/ # [###info####] [2025-08-10 11:10:54] [Opened serial port: /dev/ttyUSB_main_serial] [###info####] [2025-08-10 11:10:54] [Sent cmd: root] ----------------Serial Log Start---------------------------- [###info####] [2025-08-10 11:11:04] [Received response: ] [###info####] [2025-08-10 11:11:04] [cmd execution time: 10.0s] ----------------Serial Log End------------------------------ [###error###] [2025-08-10 11:11:04] [('/home/pi/project/autorobot/pyscript/SA525M/libs/umdp/ser_client.py', 131)] [Expected: Password] [###error###] [2025-08-10 11:11:04] [('/home/pi/project/autorobot/pyscript/SA525M/libs/umdp/ser_client.py', 132)] [Result: FAIL] [###info####] [2025-08-10 11:11:04] [Sent cmd: oelinux123] ----------------Serial Log Start---------------------------- [###info####] [2025-08-10 11:11:14] [Received response: ] [###info####] [2025-08-10 11:11:14] [cmd execution time: 10.0s] ----------------Serial Log End------------------------------ [###error###] [2025-08-10 11:11:14] [('/home/pi/project/autorobot/pyscript/SA525M/libs/umdp/ser_client.py', 131)] [Expected: #] [###error###] [2025-08-10 11:11:14] [('/home/pi/project/autorobot/pyscript/SA525M/libs/umdp/ser_client.py', 132)] [Result: FAIL] [###info####] [2025-08-10 11:11:14] [Sent cmd: cd /] [###info####] [2025-08-10 11:11:14] [Sent cmd: dev_test] ----------------Serial Log Start---------------------------- [###info####] [2025-08-10 11:11:24] [Received response: ] [###info####] [2025-08-10 11:11:24] [cmd execution time: 10.0s] ----------------Serial Log End------------------------------ [###error###] [2025-08-10 11:11:24] [('/home/pi/project/autorobot/pyscript/SA525M/libs/umdp/ser_client.py', 131)] [Expected: fibo_dev_setusb_composition] [###error###] [2025-08-10 11:11:24] [('/home/pi/project/autorobot/pyscript/SA525M/libs/umdp/ser_client.py', 132)] [Result: FAIL] [###info####] [2025-08-10 11:11:24] [Sent cmd: 6] ----------------Serial Log Start---------------------------- [###info####] [2025-08-10 11:11:34] [Received response: ] [###info####] [2025-08-10 11:11:34] [cmd execution time: 10.0s] ----------------Serial Log End------------------------------ [###error###] [2025-08-10 11:11:34] [('/home/pi/project/autorobot/pyscript/SA525M/libs/umdp/ser_client.py', 131)] [Expected: change usb mode] [###error###] [2025-08-10 11:11:34] [('/home/pi/project/autorobot/pyscript/SA525M/libs/umdp/ser_client.py', 132)] [Result: FAIL] [###info####] [2025-08-10 11:11:34] [Sent cmd: 2] ----------------Serial Log Start---------------------------- [###info####] [2025-08-10 11:11:44] [Received response: ] [###info####] [2025-08-10 11:11:44] [cmd execution time: 10.0s] ----------------Serial Log End------------------------------ [###error###] [2025-08-10 11:11:44] [('/home/pi/project/autorobot/pyscript/SA525M/libs/umdp/ser_client.py', 131)] [Expected: enable adb] [###error###] [2025-08-10 11:11:44] [('/home/pi/project/autorobot/pyscript/SA525M/libs/umdp/ser_client.py', 132)] [Result: FAIL] [###info####] [2025-08-10 11:11:44] [Sent cmd: 1] ----------------Serial Log Start---------------------------- [###info####] [2025-08-10 11:11:54] [Received response: ] [###info####] [2025-08-10 11:11:54] [cmd execution time: 10.0s] ----------------Serial Log End------------------------------ [###error###] [2025-08-10 11:11:54] [('/home/pi/project/autorobot/pyscript/SA525M/libs/umdp/ser_client.py', 131)] [Expected: set usb mode return:0] [###error###] [2025-08-10 11:11:54] [('/home/pi/project/autorobot/pyscript/SA525M/libs/umdp/ser_client.py', 132)] [Result: FAIL] [###info####] [2025-08-10 11:11:54] [Closed serial port: /dev/ttyUSB_main_serial] [###error###] [2025-08-10 11:11:54] [('/home/pi/project/autorobot/libs/../pyscript/SA525M/MODULE/USB/SA525M_MODULE_USB_SET_ADB.py', 142)] [Serial port ERR] [###error###] [2025-08-10 11:11:54] [('/home/pi/project/autorobot/libs/operator.py', 456)] [Set Test Result To Fail] [###info####] [2025-08-10 11:11:54] [adb -s 958db3d9 wait-for-device shell root] adb is already running as root [###info####] [2025-08-10 11:11:54] [adb -s 958db3d9 wait-for-device shell] Enter root Passwd:/ # date -s "2025-08-10 03:11:56" Sun Aug 10 03:11:56 UTC 2025 / # echo 25 >/data/usbmode.cfg / # sync / # reboot [###info####] [2025-08-10 11:12:07] [Time sleep 30s] ============SHELL============ adb -s 958db3d9 wait-for-device devices List of devices attached 958db3d9 device [###info####] [2025-08-10 11:12:44] [Check AVC] [###info####] [2025-08-10 11:12:44] [adb -s 958db3d9 wait-for-device shell root] Enter root Passwd:oelinux123 adb root success [###info####] [2025-08-10 11:12:44] [get root permission success.] [###info####] [2025-08-10 11:12:45] [adb -s 958db3d9 wait-for-device shell] Enter root Passwd:/ # date -s "2025-08-10 03:12:49" Sun Aug 10 03:12:49 UTC 2025 / # dmesg |grep avc / # [###info####] [2025-08-10 11:12:55] [adb -s 958db3d9 wait-for-device shell root] adb is already running as root [###info####] [2025-08-10 11:12:55] [adb -s 958db3d9 wait-for-device shell] Enter root Passwd:/ # fibo_trustzone_example -l cp: cannot stat '/gwmdata/logs': No such file or directory The relevant tzlog is stored in /tmp/tz_log. please run [adb pull /tmp/tz_log logpath] in powershell/cmd/xxx /tmp/tz_log/: 8 files pulled, 0 skipped. 4.6 MB/s (641214 bytes in 0.132s) adb: error: remote object '/etc/misc/wifi' does not exist cp: cannot stat '/home/pi/project/autorobot/libs/../log/serial_log': No such file or directory [###fail####] [2025-08-10 11:13:15] [test case run fail] 总耗时:144.2653248310089 帮我分析测试错误原因
最新发布
08-12
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值