App自动化执行报错UiAutomationService android.accessibilityservice.IAccessibilityServiceClient$Stub$Proxy@63c31ebalready registered!
2021-10-17 16:36:53:962 [Instrumentation] Caused by: java.lang.IllegalStateException: UiAutomationService android.accessibilityservice.IAccessibilityServiceClient$Stub$Proxy@63c31ebalready registered! 2021-10-17 16:36:53:962 [Instrumentation] at android.os.Parcel.createException(Parcel.java:1958) 2021-10-17 16:36:53:962 [Instrumentation] at android.os.Parcel.readException(Parcel.java:1918) 2021-10-17 16:36:53:962 [Instrumentation] at android.os.Parcel.readException(Parcel.java:1868) 2021-10-17 16:36:53:962 [Instrumentation] at android.app.IUiAutomationConnection$Stub$Proxy.connect(IUiAutomationConnection.java:255) 2021-10-17 16:36:53:963 [Instrumentation] at android.app.UiAutomation.connect(UiAutomation.java:234) 2021-10-17 16:36:53:963 [Instrumentation] at android.app.Instrumentation.getUiAutomation(Instrumentation.java:2145) 2021-10-17 16:36:53:963 [Instrumentation] at androidx.test.uiautomator.UiDevice.getUiAutomation(UiDevice.java:1129) 2021-10-17 16:36:53:963 [Instrumentation] at androidx.test.uiautomator.QueryController.<init>(QueryController.java:95) 2021-10-17 16:36:53:963 [Instrumentation] at androidx.test.uiautomator.UiDevice.<init>(UiDevice.java:109) 2021-10-17 16:36:53:963 [Instrumentation] at androidx.test.uiautomator.UiDevice.getInstance(UiDevice.java:261) 2021-10-17 16:36:53:963 [Instrumentation] at io.appium.uiautomator2.utils.Device.getUiDevice(Device.java:33) 2021-10-17 16:36:53:964 [Instrumentation] at io.appium.uiautomator2.model.internal.CustomUiDevice.<init>(CustomUiDevice.java:70) 2021-10-17 16:36:53:964 [Instrumentation] at io.appium.uiautomator2.model.internal.CustomUiDevice.getInstance(CustomUiDevice.java:80) 2021-10-17 16:36:53:964 [Instrumentation] at io.appium.uiautomator2.server.mjpeg.MjpegScreenshotStream.<clinit>(MjpegScreenshotStream.java:43) 2021-10-17 16:36:53:964 [Instrumentation] ... 32 more 2021-10-17 16:36:54:032 [Instrumentation] INSTRUMENTATION_RESULT: shortMsg=Process crashed. 2021-10-17 16:36:
通过Caused by 的错误信息搜索得知因为uiautomator的进程已经存在,需要先杀死进程
解决方法一:
1.查询adb进程:
adb shell ps | find "uiautomator"
2.杀死进程:
adb shell kill <PID>
3.如果提示" /system/bin/sh: kill: 1835: Operation not permitted ",需要切换adb为root 权限,再杀死进程
adb root
解决方法二:
重启手机