每当我尝试通过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