java.lang.SecurityException异常:权限拒绝:getIntentSender()在测试使用UiAutomation时
每当我尝试使用 UiAutomation
通过任何测试 getInstrumentation()getUiAutomation()
,该进程崩溃与此异常:
Whenever I try to use UiAutomation
in any test through getInstrumentation().getUiAutomation()
, the process crashes with this exception:
java.lang.SecurityException: Permission Denial: getIntentSender() from pid=30334, uid=2000, (need uid=1000) is not allowed to send as package android
at android.os.Parcel.readException(Parcel.java:1540)
at android.os.Parcel.readException(Parcel.java:1493)
at android.app.IUiAutomationConnection$Stub$Proxy.disconnect(IUiAutomationConnection.java:225)
at android.app.UiAutomation.disconnect(UiAutomation.java:240)
at android.app.Instrumentation.finish(Instrumentation.java:197)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:575)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1837)
任何想法,为什么?我使用的摇篮通过Android的工作室,尝试过各种版本,直接调用它通过亚行
,即使没有任何外部依赖(显然至少有18 SDK)...永远崩溃。
Any idea why? I'm using Gradle through Android Studio, tried various versions, calling it directly through adb
, even without any external dependency (and obviously with at least SDK 18)... Always crashing.
这是唯一的官方的例子,我发现: https://www.youtube.com /手表?v = _SlBHUW0ybM
This is the only official example I've found: https://www.youtube.com/watch?v=_SlBHUW0ybM
这是不是为什么UIAutomator没有捕获错误,而是一个可能的解决方法,我找到了答案。当无障碍服务上我不能,因为我收到您所描述的错误得到一个UIAutomator转储。当我关掉话语提示和/或辅助功能设置交换机接入我不再得到许可拒绝错误,UIAutomator转储成功地工作。不知道这是否会帮助你,但我可以在棒棒堂(的Nexus 5)无障碍服务每次重现您的问题ON。
This isn't an answer for why UIAutomator isn't catching the error, but rather a possible workaround that I found. When accessibility services are on I am unable to get an UIAutomator dump because I receive the error you described. When I turn off TalkBack and/or Switch Access in the Accessibility settings I no longer get the Permission Denial error and UIAutomator dump works successfully. Not sure if this will help you, but I can reproduce your issue every time with accessibility services ON in Lollipop(Nexus 5).