Repository navigation
Description
@rom1v I need to be able to synchronize the PC clipboard to the Android end in the --no-clipboard-autosync mode. However, an error occurs after pasting on version 3.3, and I found that this kind of error only occurs on Android versions below 10, This error did not occur in scrcpy3.2 version and everything works properly.The modified code and the error log after pasting are attached below. I don't know how to handle it. Seek your help.
The server modifies the code as follows:
(scrcpy-3.3\server\src\main\java\com\genymobile\scrcpy\control\Controller.java)
case ControlMessage.TYPE_SET_CLIPBOARD:
if(clipboardAutosync){
setClipboard(msg.getText(), msg.getPaste(), msg.getSequence());
}else{
Device.setClipboardText(msg.getText());
}
break;
When using --no-clipboard-autosync, pasting text to the Android end will result in the following error log:
C:\Users\Administrator\Desktop\scrcpy-win64-v3.3>scrcpy --no-clipboard-autosync
scrcpy 3.3 https://github.com/Genymobile/scrcpy
INFO: ADB device found:
INFO: --> (tcpip) 192.168.1.12:5555 device 16_X
C:\Users\Administrator\Desktop\scrcpy-win64-v3.3\scrcpy-se... file pushed, 0 skipped. 52.5 MB/s (90708 bytes in 0.002s)
adb.exe: error: more than one device/emulator
ERROR: "adb reverse" returned with value 1
WARN: 'adb reverse' failed, fallback to 'adb forward'
[server] INFO: Device: [Meizu] Meizu 16 X (Android 8.1.0)
[server] WARN: Audio disabled: it is not supported before Android 11
INFO: Renderer: direct3d
WARN: Demuxer 'audio': stream explicitly disabled by the device
INFO: Texture: 1080x2160
[server] ERROR: Exception on thread Thread[control-recv,5,main]
WARN: Djava.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()e
v at android.os.Handler.(Handler.java:204)i
c at android.os.Handler.(Handler.java:118)e
at android.content.ClipboardManager$2.(ClipboardManager.java:62)d
is at android.content.ClipboardManager.(ClipboardManager.java:62)c
o at android.app.SystemServiceRegistry$11.createService(SystemServiceRegistry.java:277)n
n at android.app.SystemServiceRegistry$11.createService(SystemServiceRegistry.java:275)e
cted
at android.app.SystemServiceRegistry$CachedServiceFetcher.getService(SystemServiceRegistry.java:1052)
at android.app.SystemServiceRegistry.getSystemService(SystemServiceRegistry.java:1004)
at android.app.ContextImpl.getSystemService(ContextImpl.java:1687)
at android.content.ContextWrapper.getSystemService(ContextWrapper.java:721)
at com.genymobile.scrcpy.FakeContext.getSystemService(FakeContext.java:102)
at com.genymobile.scrcpy.wrappers.ClipboardManager.create(ClipboardManager.java:12)
at com.genymobile.scrcpy.wrappers.ServiceManager.getClipboardManager(ServiceManager.java:89)
at com.genymobile.scrcpy.device.Device.setClipboardText(Device.java:114)
at com.genymobile.scrcpy.control.Controller.handleEvent(Controller.java:308)
at com.genymobile.scrcpy.control.Controller.control(Controller.java:218)
at com.genymobile.scrcpy.control.Controller.lambda$start$1$com-genymobile-scrcpy-control-Controller(Controller.java:226)
at com.genymobile.scrcpy.control.Controller$$ExternalSyntheticLambda1.run(D8$$SyntheticClass:0)
at java.lang.Thread.run(Thread.java:764)
Activity
Helaer commentedon Jun 13, 2025
@rom1v When clipboardAutosync=false, Calling Device.setClipboardText(msg.getText()) results in the error "Can't create handler inside thread that has not called Looper.prepare()";
This kind of error did not occur in scrcpy3.2 version. Please help me. Thank you!
Create ClipboardManager from the main thread
rom1v commentedon Jun 13, 2025
Thank you for your report.
Fixed on
devby cd3a5d5.Helaer commentedon Jun 13, 2025
This problem has been solved. Thank you.
Merge tag 'v3.3.1' of https://github.com/Genymobile/scrcpy into master