Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Screenshots not working with Android 23 #133

Open
gregersn opened this issue Jun 10, 2024 · 3 comments
Open

Screenshots not working with Android 23 #133

gregersn opened this issue Jun 10, 2024 · 3 comments

Comments

@gregersn
Copy link
Contributor

At some point between the current version (2.7.2) and 2.3.1 screenshots with Android 23 (on emulator) is no longer working.
I see there has been some back and forth with the screenshot function since then, but some of the changes has made it no longer usable with Android 23.

@codeskyblue
Copy link
Member

Is "adb shell screencap" works?

@gregersn
Copy link
Contributor Author

gregersn commented Jun 12, 2024 via email

@Gennadiyev
Copy link

I have not investigated whether it is an Android 23 problem or some ADB version problem. If you run into some error like:

screencap error: cannot identify image file <_io.BytesIO object at 0x000002202178E2A0>

TL;DR: Then your fix could be as simple as passing a display_id parameter to Device.screenshot method.


If you dive deeper to the bytes provided by the __screencap function, you will see these lines at the top of the output file:

[Warning] Multiple displays were found, but no display id was specified! Defaulting to the first display found, however this default is not guaranteed to be consistent across captures. A display id should be specified.
A display ID can be specified with the [-d display-id] option.
See "dumpsys SurfaceFlinger --display-id" for valid display IDs.

Followed by a PNG byte sequence. So the solution is quite trivial.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants