Genymobile / scrcpy

Display and control your Android device
Apache License 2.0
108.58k stars 10.45k forks source link

[BUG] Can't click or interact with Scrcpy window on desktop #3845

Open igorteuri opened 1 year ago

igorteuri commented 1 year ago

Environment

I can miror my screen on desktop, using usb cable. But I can't click or interact with the screen. It returns several terminal errors.

When I open Scrcpy, the following error is prompted

[server] INFO: Device: Xiaomi 22021211RG (Android 13)
[server] ERROR: Could not invoke method
java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Method.invoke(Native Method)
        at com.genymobile.scrcpy.wrappers.InputManager.injectInputEvent(InputManager.java:37)
        at com.genymobile.scrcpy.Device.injectEvent(Device.java:192)
        at com.genymobile.scrcpy.Device.injectKeyEvent(Device.java:203)
        at com.genymobile.scrcpy.Device.pressReleaseKeycode(Device.java:211)
        at com.genymobile.scrcpy.Device.pressReleaseKeycode(Device.java:216)
        at com.genymobile.scrcpy.Controller.control(Controller.java:70)
        at com.genymobile.scrcpy.Controller.lambda$start$0$com-genymobile-scrcpy-Controller(Controller.java:90)
        at com.genymobile.scrcpy.Controller$$ExternalSyntheticLambda0.run(Unknown Source:2)
        at java.lang.Thread.run(Thread.java:1012)
Caused by: java.lang.SecurityException: Injecting input events requires the caller (or the source of the instrumentation, if any) to have the INJECT_EVENTS permission.
        at android.os.Parcel.createExceptionOrNull(Parcel.java:3011)
        at android.os.Parcel.createException(Parcel.java:2995)
        at android.os.Parcel.readException(Parcel.java:2978)
        at android.os.Parcel.readException(Parcel.java:2920)
        at android.hardware.input.IInputManager$Stub$Proxy.injectInputEventToTarget(IInputManager.java:1294)
        at android.hardware.input.InputManager.injectInputEvent(InputManager.java:1153)
        at android.hardware.input.InputManager.injectInputEvent(InputManager.java:1182)
        ... 10 more
Caused by: android.os.RemoteException: Remote stack trace:
        at com.android.server.input.InputManagerService.injectInputEventToTarget(InputManagerService.java:916)
        at android.hardware.input.IInputManager$Stub.onTransact(IInputManager.java:617)
        at android.os.Binder.execTransactInternal(Binder.java:1285)
        at android.os.Binder.execTransact(Binder.java:1249)

INFO: Renderer: direct3d
INFO: Initial texture: 1080x2400

When I try any kind of click or interaction, this is the error I receive.

[server] ERROR: Could not invoke method
java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Method.invoke(Native Method)
        at com.genymobile.scrcpy.wrappers.InputManager.injectInputEvent(InputManager.java:37)
        at com.genymobile.scrcpy.Device.injectEvent(Device.java:192)
        at com.genymobile.scrcpy.Device.injectEvent(Device.java:196)
        at com.genymobile.scrcpy.Controller.injectTouch(Controller.java:320)
        at com.genymobile.scrcpy.Controller.handleEvent(Controller.java:134)
        at com.genymobile.scrcpy.Controller.control(Controller.java:83)
        at com.genymobile.scrcpy.Controller.lambda$start$0$com-genymobile-scrcpy-Controller(Controller.java:90)
        at com.genymobile.scrcpy.Controller$$ExternalSyntheticLambda0.run(Unknown Source:2)
        at java.lang.Thread.run(Thread.java:1012)
Caused by: java.lang.SecurityException: Injecting input events requires the caller (or the source of the instrumentation, if any) to have the INJECT_EVENTS permission.
        at android.os.Parcel.createExceptionOrNull(Parcel.java:3011)
        at android.os.Parcel.createException(Parcel.java:2995)
        at android.os.Parcel.readException(Parcel.java:2978)
        at android.os.Parcel.readException(Parcel.java:2920)
        at android.hardware.input.IInputManager$Stub$Proxy.injectInputEventToTarget(IInputManager.java:1294)
        at android.hardware.input.InputManager.injectInputEvent(InputManager.java:1153)
        at android.hardware.input.InputManager.injectInputEvent(InputManager.java:1182)
        ... 10 more
Caused by: android.os.RemoteException: Remote stack trace:
        at com.android.server.input.InputManagerService.injectInputEventToTarget(InputManagerService.java:916)
        at android.hardware.input.IInputManager$Stub.onTransact(IInputManager.java:617)
        at android.os.Binder.execTransactInternal(Binder.java:1285)
        at android.os.Binder.execTransact(Binder.java:1249)

[server] ERROR: Could not invoke method
java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Method.invoke(Native Method)
        at com.genymobile.scrcpy.wrappers.InputManager.injectInputEvent(InputManager.java:37)
        at com.genymobile.scrcpy.Device.injectEvent(Device.java:192)
        at com.genymobile.scrcpy.Device.injectEvent(Device.java:196)
        at com.genymobile.scrcpy.Controller.injectTouch(Controller.java:320)
        at com.genymobile.scrcpy.Controller.handleEvent(Controller.java:134)
        at com.genymobile.scrcpy.Controller.control(Controller.java:83)
        at com.genymobile.scrcpy.Controller.lambda$start$0$com-genymobile-scrcpy-Controller(Controller.java:90)
        at com.genymobile.scrcpy.Controller$$ExternalSyntheticLambda0.run(Unknown Source:2)
        at java.lang.Thread.run(Thread.java:1012)
Caused by: java.lang.SecurityException: Injecting input events requires the caller (or the source of the instrumentation, if any) to have the INJECT_EVENTS permission.
        at android.os.Parcel.createExceptionOrNull(Parcel.java:3011)
        at android.os.Parcel.createException(Parcel.java:2995)
        at android.os.Parcel.readException(Parcel.java:2978)
        at android.os.Parcel.readException(Parcel.java:2920)
        at android.hardware.input.IInputManager$Stub$Proxy.injectInputEventToTarget(IInputManager.java:1294)
        at android.hardware.input.InputManager.injectInputEvent(InputManager.java:1153)
        at android.hardware.input.InputManager.injectInputEvent(InputManager.java:1182)
        ... 10 more

I am layman about this kind of stuff. Is there any way to solve this?

rom1v commented 1 year ago

https://github.com/Genymobile/scrcpy/blob/master/FAQ.md#mouse-and-keyboard-do-not-work https://github.com/Genymobile/scrcpy#prerequisites

Leskur commented 1 year ago

我遇到了同样的问题,你需要打开USB调试(安全设置)选项。 然后重启你的设备,这一步是必要的!

aiy365 commented 9 months ago

我遇到了同样的问题,你需要打开USB调试(安全设置)选项。 然后重启你的设备,这一步是必要的!

oppo是没有这个设置的 只有一个【USB调试】