python 自动化uiautomator 报错:ioerror RPC server not started解决办法

在使用最新的VIVO X21手机过程中,自动化脚本报错:

Traceback (most recent call last):
File "main.py", line 75, in
Automated.test_auto_test()
File "main.py", line 22, in test_auto_test
QQLive = Record_QQLive(serial='2973cab8')
File "/mnt/f/AutoStartTime/Record_QQLive.py", line 25, in init
self.test_initEnv()
File "/mnt/f/AutoStartTime/Record_QQLive.py", line 93, in test_initEnv
self.dins.pressHome()
File "/mnt/f/AutoStartTime/androidDrive/deviceInstance.py", line 85, in pressHome
self.ins.pressHome()
File "/mnt/f/AutoStartTime/androidDrive/deviceInstance.py", line 239, in pressHome
self._sys.pressHome()
File "/mnt/f/AutoStartTime/androidDrive/sysActions.py", line 49, in pressHome
self._d.press("home")
File "/mnt/f/AutoStartTime/androidDrive/helper.py", line 140, in call
return self.func(*args, **kwargs)
File "/mnt/f/AutoStartTime/androidDrive/automatorDevice.py", line 233, in _press
return self.server.jsonrpc.pressKey(str(key))
File "/mnt/f/AutoStartTime/androidDrive/automatorServer.py", line 81, in wrapper
server.start(timeout=30)
File "/mnt/f/AutoStartTime/androidDrive/automatorServer.py", line 122, in start
**raise IOError("RPC server not started!")
IOError: RPC server not started!
**

出错原因:
7.0的手机不会自动安装app-uiautomator.apk和app-uiautomator-test.apk,手动装一下就可以了

解决办法如下:
1. adb shell pm uninstall com.github.uiautomator
2. adb shell pm uninstall com.github.uiautomator.test
3. adb install app-uiautomator.apk
4. adb install app-uiautomator-test.apk
5. adb push bundle.jar /data/local/tmp/
6. adb push uiautomator-stub.jar /data/local/tmp/

相关文件下载地址:
https://github.com/jiankehtt/uiautomator/tree/master/uiautomator/libs

python 自动化uiautomator 报错:ioerror RPC server not started解决办法