报错信息
[Instrumentation] Caused by: java.lang.IllegalStateException: UiAutomationService android.accessibilityservice.IAccessibilityServiceClient
S
t
u
b
Stub
StubProxy@af533b6already registered!
[Instrumentation] at android.os.Parcel.createException(Parcel.java:2079)
[Instrumentation] at android.os.Parcel.readException(Parcel.java:2039)
[Instrumentation] at android.os.Parcel.readException(Parcel.java:1987)
[Instrumentation] at android.app.IUiAutomationConnection
S
t
u
b
Stub
StubProxy.connect(IUiAutomationConnection.java:427)
[Instrumentation] at android.app.UiAutomation.connect(UiAutomation.java:241)
[Instrumentation] at android.app.Instrumentation.getUiAutomation(Instrumentation.java:2160)
[Instrumentation] at androidx.test.uiautomator.UiDevice.getUiAutomation(UiDevice.java:1129)
[Instrumentation] at androidx.test.uiautomator.QueryController.(QueryController.java:95)
[Instrumentation] at androidx.test.uiautomator.UiDevice.(UiDevice.java:109)
[Instrumentation] at androidx.test.uiautomator.UiDevice.getInstance(UiDevice.java:261)
[Instrumentation] at io.appium.uiautomator2.utils.Device.getUiDevice(Device.java:40)
[Instrumentation] at io.appium.uiautomator2.model.internal.CustomUiDevice.(CustomUiDevice.java:75)
[Instrumentation] at io.appium.uiautomator2.model.internal.CustomUiDevice.getInstance(CustomUiDevice.java:90)
[Instrumentation] at io.appium.uiautomator2.server.mjpeg.MjpegScreenshotStream.(MjpegScreenshotStream.java:43)
通过Caused by 的错误信息搜索得知因为uiautomator的进程已经存在,需要先杀死进程
解决方法:
.查询adb进程:
adb shell ps | find "uiautomator"
杀死进程:
adb shell kill
如果提示" /system/bin/sh: kill: 1835: Operation not permitted ",需要切换adb为root 权限,再杀死进程
adb root
再重新启动程序