排查/解决过程:
1、重新执行一次 -> 现象上来看,发现手机上没有打开目标APP,一直报相同错误
Original error: The instrumentation process cannot be initialized
2、报错里有:at UiAutomator2Server.startSession,初步怀疑是 io.appium.uiautomator2.server app问题
- 查看 Config 里 skipServerInstallation: true
- 改成 skipServerInstallation: false
3、重新执行一次,成功✅
4、然后再改下 skipServerInstallation: true
(这样下次执行,也不会重复安装io.appium.uiautomator2.server)
根本原因:
新设备没有安装 io.appium.uiautomator2.server,
并且本地配置里 skipServerInstallation: true,
->
这样就跳过安装io.appium.uiautomator2.server ,
导致新设备无法正常启动server
后续排查思路:
如出现类似报错,继续查看 appium 相关的 app 执行情况,如setting、uiautomator2.server 、uiautomator2.test
详细报错信息:
2021-01-07 10:09:47:443 [W3C] Encountered internal error running command: Error: The instrumentation process cannot be initialized. Make sure the application under test does not crash and investigate the logcat output.
2021-01-07 10:09:47:443 [W3C] at Object.errorAndThrow (/usr/local/lib/node_modules/appium/node_modules/appium-support/lib/logging.js:94:35)
2021-01-07 10:09:47:443 [W3C] at UiAutomator2Server.startSession (/usr/local/lib/node_modules/appium/node_modules/appium-uiautomator2-driver/lib/uiautomator2.js:233:13)
2021-01-07 10:09:47:443 [W3C] at AndroidUiautomator2Driver.startUiAutomator2Session (/usr/local/lib/node_modules/appium/node_modules/appium-uiautomator2-driver/lib/driver.js:390:5)
2021-01-07 10:09:47:443 [W3C] at AndroidUiautomator2Driver.createSession (/usr/local/lib/node_modules/appium/node_modules/appium-uiautomator2-driver/lib/driver.js:221:7)
2021-01-07 10:09:47:444 [W3C] at AppiumDriver.createSession (/usr/local/lib/node_modules/appium/lib/appium.js:358:35)
2021-01-07 10:09:47:455 [W3C] Destroying socket connection
2021-01-07 10:09:47:456 [HTTP] <-- POST /wd/hub/session 500 6846 ms - 771
一个其他情况(相同报错)
现象:
开启 weditor 时,开启inspector 启动(start session) 时必现
解决:
关闭 weditor,插拔下数据线
详细报错:
2022-06-20 20:00:25:907 - [debug] [W3C] Encountered internal error running command: Error: The instrumentation process cannot be initialized. Make sure the application under test does not crash and investigate the logcat output.
2022-06-20 20:00:25:907 - [debug] [W3C] at Object.errorAndThrow (/usr/local/lib/node_modules/appium/node_modules/appium-support/lib/logging.js:94:35)
2022-06-20 20:00:25:907 - [debug] [W3C] at UiAutomator2Server.startSession (/usr/local/lib/node_modules/appium/node_modules/appium-uiautomator2-driver/lib/uiautomator2.js:247:13)
2022-06-20 20:00:25:907 - [debug] [W3C] at AndroidUiautomator2Driver.startUiAutomator2Session (/usr/local/lib/node_modules/appium/node_modules/appium-uiautomator2-driver/lib/driver.js:416:5)
2022-06-20 20:00:25:908 - [debug] [W3C] at AndroidUiautomator2Driver.createSession (/usr/local/lib/node_modules/appium/node_modules/appium-uiautomator2-driver/lib/driver.js:229:7)
2022-06-20 20:00:25:908 - [debug] [W3C] at AppiumDriver.createSession (/usr/local/lib/node_modules/appium/lib/appium.js:387:35)
2022-06-20 20:00:25:910 - [HTTP] <-- POST /wd/hub/session 500 10630 ms - 771
2022-06-20 20:00:25:910 - [HTTP]