Skip to content
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

java.lang.NoSuchMethodException: startActivityAsUserWithFeature #4704

Closed
2 tasks done
anotheruserofgithub opened this issue Feb 26, 2024 · 2 comments
Closed
2 tasks done

Comments

@anotheruserofgithub
Copy link

  • I have read the FAQ.
  • I have searched in existing issues.

Environment

  • OS: Ubuntu 18.04
  • scrcpy version: uhid.27 (based on 2.3.1)
  • installation method: manual
  • device model: custom ROM
  • Android version: 8.1

Describe the bug

Using the new MOD+k shortcut (in UHID) failed in ActivityManager.startActivityAsUserWithFeature() with this backtrace:

$ scrcpy --keyboard=uhid --mouse=uhid
scrcpy 2.3.1 <https://github.com/Genymobile/scrcpy>
INFO: ADB device found:
INFO:     -->   (usb)  ***                      device  ***
/usr/local/share/scrcpy/scrcpy-server: 1 file pushed. 4.2 MB/s (68615 bytes in 0.016s)
[server] INFO: Device: *** (Android 8.1.0)
[server] WARN: Audio disabled: it is not supported before Android 11
INFO: Renderer: opengl
INFO: OpenGL version: 4.6.0 NVIDIA 535.146.02
INFO: Trilinear filtering enabled
WARN: Demuxer 'audio': stream explicitly disabled by the device
INFO: Texture: 1280x800
[server] ERROR: Could not invoke method
java.lang.NoSuchMethodException: startActivityAsUserWithFeature [interface android.app.IApplicationThread, class java.lang.String, class java.lang.String, class android.content.Intent, class java.lang.String, interface android.os.IBinder, class java.lang.String, int, int, class android.app.ProfilerInfo, class android.os.Bundle, int]
	at java.lang.Class.getMethod(Class.java:2068)
	at java.lang.Class.getMethod(Class.java:1690)
	at com.genymobile.scrcpy.wrappers.ActivityManager.getStartActivityAsUserWithFeatureMethod(ActivityManager.java:115)
	at com.genymobile.scrcpy.wrappers.ActivityManager.startActivityAsUserWithFeature(ActivityManager.java:124)
	at com.genymobile.scrcpy.Controller.openHardKeyboardSettings(Controller.java:457)
	at com.genymobile.scrcpy.Controller.handleEvent(Controller.java:214)
	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:764)

The reason is that my device uses SDK 27 while this method was added later (SDK 30?) in this commit. So when startActivityAsUserWithFeature() fails you should probably use startActivityAsUser() instead, because it works the same way (callingFeatureId is null). Maybe startActivityAsUser() should be used directly, even if it's deprecated?

rom1v added a commit that referenced this issue Feb 26, 2024
Call the older startActivityAsUser() instead of
startActivityAsUserWithFeature() so that it also works on older Android
versions.

Fixes #4704 <#4704>
@rom1v
Copy link
Collaborator

rom1v commented Feb 26, 2024

Thank you. Fixed by abc64b4 on uhid.28.

@anotheruserofgithub
Copy link
Author

Thanks, it's working like a charm. :)

rom1v added a commit that referenced this issue Feb 27, 2024
Call the older startActivityAsUser() instead of
startActivityAsUserWithFeature() so that it also works on older Android
versions.

Fixes #4704 <#4704>
rom1v added a commit that referenced this issue Feb 29, 2024
Call the older startActivityAsUser() instead of
startActivityAsUserWithFeature() so that it also works on older Android
versions.

Fixes #4704 <#4704>
rom1v added a commit that referenced this issue Feb 29, 2024
Call the older startActivityAsUser() instead of
startActivityAsUserWithFeature() so that it also works on older Android
versions.

Fixes #4704 <#4704>
rom1v added a commit that referenced this issue Feb 29, 2024
Call the older startActivityAsUser() instead of
startActivityAsUserWithFeature() so that it also works on older Android
versions.

Fixes #4704 <#4704>
rom1v added a commit that referenced this issue Feb 29, 2024
Call the older startActivityAsUser() instead of
startActivityAsUserWithFeature() so that it also works on older Android
versions.

Fixes #4704 <#4704>
rom1v added a commit that referenced this issue Feb 29, 2024
Call the older startActivityAsUser() instead of
startActivityAsUserWithFeature() so that it also works on older Android
versions.

Fixes #4704 <#4704>
rom1v added a commit that referenced this issue Feb 29, 2024
Call the older startActivityAsUser() instead of
startActivityAsUserWithFeature() so that it also works on older Android
versions.

Fixes #4704 <#4704>
@rom1v rom1v closed this as completed in 54dede3 Mar 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants