-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Copy-paste broken on Honor Magic5 with Android 14 (getPrimaryClip NoSuchMethodException) #5073
Comments
Which scrcpy version? |
|
Please replace this binary in the scrcpy 2.5 release folder and test:
diffdiff --git a/server/src/main/java/com/genymobile/scrcpy/wrappers/ClipboardManager.java b/server/src/main/java/com/genymobile/scrcpy/wrappers/ClipboardManager.java
index bdbba21df..f8b5ec6ef 100644
--- a/server/src/main/java/com/genymobile/scrcpy/wrappers/ClipboardManager.java
+++ b/server/src/main/java/com/genymobile/scrcpy/wrappers/ClipboardManager.java
@@ -82,9 +82,16 @@ public final class ClipboardManager {
// fall-through
}
- getPrimaryClipMethod = manager.getClass()
- .getMethod("getPrimaryClip", String.class, String.class, String.class, String.class, int.class, int.class, boolean.class);
- getMethodVersion = 5;
+ try {
+ getPrimaryClipMethod = manager.getClass().getMethod("getPrimaryClip", String.class, String.class, String.class, String.class, int.class, int.class, boolean.class);
+ getMethodVersion = 5;
+ return getPrimaryClipMethod;
+ } catch (NoSuchMethodException e) {
+ // fall-through
+ }
+
+ getPrimaryClipMethod = manager.getClass().getMethod("getPrimaryClip", String.class, String.class, int.class, int.class, String.class);
+ getMethodVersion = 6;
}
return getPrimaryClipMethod;
}
@@ -145,8 +152,10 @@ public final class ClipboardManager {
case 4:
// The last boolean parameter is "userOperate"
return (ClipData) method.invoke(manager, FakeContext.PACKAGE_NAME, null, FakeContext.ROOT_UID, 0, true);
- default:
+ case 5:
return (ClipData) method.invoke(manager, FakeContext.PACKAGE_NAME, null, null, null, FakeContext.ROOT_UID, 0, true);
+ default:
+ return (ClipData) method.invoke(manager, FakeContext.PACKAGE_NAME, null, FakeContext.ROOT_UID, 0, null);
}
}
|
Thank you very much, the problem with the clipboard was solved perfectly:
But there is still a problem, I wonder if it can also be solved:
|
Yes: #4943 |
Merged: 7924295 |
Please read the prerequisites to run scrcpy.
Also read the FAQ and check if your issue already exists.
Environment
Describe the bug
[server] ERROR: Could not invoke method
java.lang.NoSuchMethodException: android.content.IClipboard$Stub$Proxy.getPrimaryClip [class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, int, int, boolean]
at java.lang.Class.getMethod(Class.java:2937)
at java.lang.Class.getMethod(Class.java:2449)
at com.genymobile.scrcpy.wrappers.ClipboardManager.getGetPrimaryClipMethod(ClipboardManager.java:64)
at com.genymobile.scrcpy.wrappers.ClipboardManager.getText(ClipboardManager.java:152)
at com.genymobile.scrcpy.Device.getClipboardText(Device.java:290)
at com.genymobile.scrcpy.Device$3.dispatchPrimaryClipChanged(Device.java:143)
at android.content.IOnPrimaryClipChangedListener$Stub.onTransact(IOnPrimaryClipChangedListener.java:84)
at android.os.Binder.execTransactInternal(Binder.java:1371)
at android.os.Binder.execTransact(Binder.java:1310)
——The above issues that occur during the use of Scrcpy prevent the copied content on the phone from being transmitted to the computer
The text was updated successfully, but these errors were encountered: