android – java.lang.SecurityException:在测试中使用UiAutomation时的权限拒绝:getIntentSender()

每当我尝试通过getInstrumentation().getUiAutomation()的任何测试中使用 UiAutomation时,进程会遇到这个异常:
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)

任何想法为什么?我正在使用Gradle通过Android Studio,尝试各种版本,通过adb直接调用它,即使没有任何外部依赖(显然至少包含SDK 18)…总是崩溃.

这是我发现的唯一官方例子:https://www.youtube.com/watch?v=_SlBHUW0ybM

解决方法

这不是UIAutomator为什么不捕捉错误的答案,而是我发现的一种可能的解决方法.当访问服务启动时,我无法获取UIAutomator转储,因为我收到您所描述的错误.当我在“辅助功能”设置中关闭“话语提示”和/或“开关访问”时,我不再获得权限拒绝错误,并且UIAutomator转储成功.不知道这是否会帮助你,但是我可以在Lollipop(Nexus 5)中每次都可以使用无障碍服务启用您的问题.

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...