每当我尝试UiAutomation在任何测试中使用时getInstrumentation().getUiAutomation(),该进程都会因此异常而崩溃:
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)
Run Code Online (Sandbox Code Playgroud)
知道为什么吗?我正在使用Gradle通过Android Studio,尝试各种版本,直接调用它adb,即使没有任何外部依赖(显然至少有SDK 18)...总是崩溃.
这是我发现的唯一官方示例:https://www.youtube.com/watch?v =_SlBHUW0ybM