一、前置说明
UnknownError: An unknown server-side error occurred while processing the command. Original error: Error executing adbExec. Original error: ‘Command ‘D:\ProgramFiles\Android\android-sdk\platform-tools\adb.exe -P 5037 -s 9YS0220306003185 install -r C:\Users\xyouw\.appium\node_modules\appium-uiautomator2-driver\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-debug-androidTest.apk’ timed out after 20000ms’. Try to increase the 20000ms adb execution timeout represented by ‘uiautomator2ServerInstallTimeout’ capability
二、操作步骤
先在capabilities
中设置 uiautomator2ServerInstallTimeout
的时间,再尝试运行:
capabilities = { "platformName": "Android", "automationName": "uiautomator2", "deviceName": "127.0.0.1:62001", "app": "D:\\resources\\ApiDemos-debug.apk", "uiautomator2ServerInstallTimeout": 60000, # 添加这一行 }
如果仍然安装不成功,可以手动进行安装。在日志中找到 apk 的位置,以我的日志为例:C:\\Users\\xyouw\\.appium\\node_modules\\appium-uiautomator2-driver\\node_modules\\appium-uiautomator2-server\\apks\\appium-uiautomator2-server-debug-androidTest.apk,将这段日志复制出来并转换成:C:\Users\xyouw\.appium\node_modules\appium-uiautomator2-driver\node_modules\appium-uiautomator2-server\apks\
,然后在资源文件管理器中打开:
右键,在终端中打开,执行 adb install 命令,手动安装这两个包即可:
adb install .\appium-uiautomator2-server-debug-androidTest.apk adb install .\appium-uiautomator2-server-v5.12.16.apk