You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Appium自动化测试应用启动后闪退,报Unable to create a new remote session错误

解决Appium自动化测试应用启动闪退+ECONNRESET连接错误

我来帮你排查这个Appium启动闪退并抛出ECONNRESET连接错误的问题,这个错误我在日常调试中碰到过不少次,大多和连接稳定性、配置匹配度或者驱动兼容性有关,咱们一步步来定位解决:

首先先把你遇到的错误日志整理出来,方便对照排查:

FAILED CONFIGURATION: @BeforeSuite setUp
org.openqa.selenium.SessionNotCreatedException: Unable to create a new remote session. Please check the server log for more details.
Original error: An unknown server-side error occurred while processing the command. Original error: Could not proxy command to remote server. Original error: Error: read ECONNRESET
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48'
System info: host: 'IN-6J1QPN2-10', ip: '10.0.75.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_171'
Driver info: driver.version: AndroidDriver
remote stacktrace: UnknownError: An unknown server-side error occurred while processing the command. Original error: Could not proxy command to remote server. Original error: Error: read ECONNRESET at JWProxy.command
System info: host: 'IN-6J1QPN2-10', ip: '10.0.75.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_171'
Driver info: driver.version: AndroidDriver

一、先排查设备与Appium Server的连接稳定性

  • 首先确认设备连接状态:打开命令行运行adb devices,确保你的设备/模拟器显示为device状态,如果是offline,重新插拔USB(真机)或者重启模拟器
  • 重置adb服务:运行adb kill-server,再执行adb start-server,之后重新检查设备连接
  • 检查端口占用:Appium默认用4723端口,Windows下可以用netstat -ano | findstr :4723查看是否有其他进程占用该端口,如果有,要么结束占用进程,要么启动Appium时指定新端口(比如appium -p 4724)

二、核对Desired Capabilities核心配置

这些配置错误是导致启动失败的高发原因,一定要仔细核对:

  • appPackage和appActivity:必须是应用的正确包名和启动页Activity。你可以手动打开应用后,运行adb shell dumpsys window | findstr mCurrentFocus获取当前活跃的Activity信息,确保和配置完全一致
  • platformVersion:要和设备/模拟器的Android版本精确匹配,比如设备是Android 11,就不能写成10
  • automationName:Android 8.0及以上版本建议使用UiAutomator2,不要用老旧的UiAutomator1
  • app路径:确保APK文件路径没有空格或特殊字符,最好用绝对路径

三、修复Appium与UiAutomator2驱动的兼容性

  • 检查Appium版本和UiAutomator2驱动版本是否匹配:比如Appium 1.22.x以上建议搭配UiAutomator2 2.0.x以上版本
  • 重新安装UiAutomator2驱动:可以通过Appium Inspector的「Install Drivers」功能重新安装,或者用命令行执行appium driver install uiautomator2

四、排查应用本身的异常

  • 先手动启动应用,如果手动也闪退,那问题出在应用本身,和Appium无关,需要先修复应用包
  • 如果手动启动正常,尝试在Desired Capabilities中添加noReset: true(或fullReset: false),避免每次测试都重置应用数据,有些应用重置后会出现启动异常
  • 部分应用有自动化检测机制,可尝试添加disableWindowAnimation: true关闭动画,或者在adb中执行adb shell settings put global window_animation_scale 0等命令关闭系统动画,降低被检测的概率

内容的提问来源于stack exchange,提问作者Ekta Sidhu

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.12 03:52:30