Genymobile / scrcpy

Display and control your Android device
Apache License 2.0
103.02k stars 10.01k forks source link

cannot control mobile screen from laptop #4858

Closed nerkanik closed 1 month ago

nerkanik commented 1 month ago

Environment

Describe the bug

Mobile screen is mirrored when I open scrcpy.exe & usb debugging is enabled. But when I click anywhere on anywhere on mobile screen mirrored on laptop with mouse it does not work, instead I get error like below:

scrcpy 2.4 https://github.com/Genymobile/scrcpy INFO: ADB device found: INFO: --> (usb) dc8517f0 device 2109119DI C:\Users\Lenovo\Downloads\scrcpy-win64-v2.4\scrcpy-win64-v... file pushed, 0 skipped. 12.7 MB/s (69007 bytes in 0.005s) [server] INFO: Device: [Xiaomi] Xiaomi 2109119DI (Android 13) INFO: Renderer: direct3d INFO: Texture: 1080x2400 [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:58) at com.genymobile.scrcpy.Device.injectEvent(Device.java:230) at com.genymobile.scrcpy.Device.injectEvent(Device.java:234) at com.genymobile.scrcpy.Controller.injectTouch(Controller.java:362) at com.genymobile.scrcpy.Controller.handleEvent(Controller.java:162) at com.genymobile.scrcpy.Controller.control(Controller.java:97) at com.genymobile.scrcpy.Controller.lambda$start$0$com-genymobile-scrcpy-Controller(Controller.java:105) at com.genymobile.scrcpy.Controller$$ExternalSyntheticLambda1.run(Unknown Source:4) 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

nerkanik commented 1 month ago

had to enable USB debugging (security setting) too to control via keyboard/mouse