坑点一:启动appium会话报错 An unknown server-side error occurred while processing the command. Original error: The instrumentation process cannot be initialized. Make sure the application under test does not crash and investigate the logcat output.
使用豆瓣APP和夜神模拟器进行测试:
原因: 起初以为没有安装手机上没有安装uiautonator2对应的应用导致,可以检查应用管理发现已经安装成功,网上找了很多资料都解决不了。后来发现以前的电脑上可以正常使用,对比后发现原来是JDK的问题,这个电脑装的最新版的JDK,不是JDK1.8
解决方案: 卸载原有JDK,安装JDK1.8,并配置环境变量
坑点二:使用真机测试时,报错 An unknown server-side error occurred while processing the command. Original error: The instrumentation process cannot be initialized. Make sure the application under test does not crash and investigate the logcat output.
解决方案: 最后在全部日志中查找出,If you wish to use that automation instead of UiAutomator2, please add ‘automationName=UiAutomator1’ to your desired capabilities
所以,只需要在启动项中加入automationName=UiAutomator1
即可
注:写json格式的数据时,记得后面需要带逗号,我就忘记逗号然后一直报错