当我在 Android Studio 中运行 UIAutomator 时,有时会出现崩溃。
W/ActivityManager: Crash of app com.example.testsample running instrumentation ComponentInfo{com.example.testsample.test/android.support.test.runner.AndroidJUnitRunner}
07-16 19:19:34.191 7834-7850/? W/Binder: Binder call failed.
java.lang.SecurityException: Calling from not trusted UID!
at android.app.UiAutomationConnection.throwIfCalledByNotTrustedUidLocked(UiAutomationConnection.java:427)
at android.app.UiAutomationConnection.shutdown(UiAutomationConnection.java:324)
at android.app.IUiAutomationConnection$Stub.onTransact(IUiAutomationConnection.java:209)
at android.os.Binder.execTransact(Binder.java:570)
但并不是每次都显示。当没有显示时我可以成功运行。 有人可以帮助我吗? 谢谢。
private void throwIfCalledByNotTrustedUidLocked() {
final int callingUid = Binder.getCallingUid();
if (callingUid != mOwningUid && mOwningUid != Process.SYSTEM_UID
&& callingUid != 0 /*root*/) {
throw new SecurityException("Calling from not trusted UID!");
}
}
这是抛出错误的方法。也许
uid
与进程 uid
不同,或者该设备上的 uid
不是 root
。也许您可以在应用程序中添加一些打印来找出答案。
uiAutomation.takeScreenshot() 出现的如何解决