[Android]ADB调试: SecurityException: Injecting to another application requires INJECT_EVENTS permissio

问题描述

使用ADB工具调试安卓设备时报此错误:

C:\Users\Johnny>adb shell input text "Hello"
java.lang.SecurityException: Injecting to another application requires INJECT_EVENTS permission
        at android.os.Parcel.createException(Parcel.java:2074)
        at android.os.Parcel.readException(Parcel.java:2042)
        at android.os.Parcel.readException(Parcel.java:1990)
        at android.hardware.input.IInputManager$Stub$Proxy.injectInputEvent(IInputManager.java:991)
        at android.hardware.input.InputManager.injectInputEvent(InputManager.java:886)
        at com.android.commands.input.Input.injectKeyEvent(Input.java:386)
        at com.android.commands.input.Input.access$100(Input.java:41)
        at com.android.commands.input.Input$InputText.sendText(Input.java:175)
        at com.android.commands.input.Input$InputText.run(Input.java:141)
        at com.android.commands.input.Input.onRun(Input.java:108)
        at com.android.internal.os.BaseCommand.run(BaseCommand.java:56)
        at com.android.commands.input.Input.main(Input.java:71)
        at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
        at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:380)
Caused by: android.os.RemoteException: Remote stack trace:
        at com.android.server.input.InputManagerService.injectInputEventInternal(InputManagerService.java:754)
        at com.android.server.input.InputManagerService.injectInputEvent(InputManagerService.java:728)
        at android.hardware.input.IInputManager$Stub.onTransact(IInputManager.java:451)
        at android.os.Binder.execTransactInternal(Binder.java:1021)
        at android.os.Binder.execTransact(Binder.java:994)
[Android]ADB调试: SecurityException: Injecting to another application requires INJECT_EVENTS permissio

解决方案

开发者选项里面---》打开USB调试(安全设置)

备注:打开这个就允许通过USB调试修改权限或模拟点击事件了

X 参考文献

上一篇:JMeter测试出现java.net.SocketException: Permission denied: connect 解决方案


下一篇:Android权限