android-emulator-runner
android-emulator-runner copied to clipboard
Blank/Empty screenshot
Hello,
A part of another project, we were playing around if it's possible to take an screenshot when running some tests. We are having problems with that since all the screenshots we pull are empty/blank.
To reproduce it, it's as simple ase using the following steps in a github action.
- name: Test
uses: reactiveCircus/android-emulator-runner@v2
with:
api-level: 29
force-avd-creation: false
arch: x86_64
target: google_apis
profile: Nexus 6
script: adb shell screencap -p /data/local/tmp/Screenshot.png; adb pull /data/local/tmp/Screenshot.png Screenshot.png;
- name: Upload screenshot
if: always()
uses: actions/upload-artifact@v3
with:
name: device-screenshot
path: ./*Screenshot.png
Are we missing something? is it expected that screenshots are blank/empty when using emulators inside github actions?
@cmonfortep By default, this action starts the emulator headlessly with -no-window. This might be the reason screenshots are not showing up. Try explicitly overriding that in your emulator options and let me know how your screenshots are appearing after.
EDIT Screenshots are possible with -no-window
Thanks, I've tested it multiple times with different setups and I'm always getting the same emtpy/blank png.
This is the latest I tested, and no luck.
- name: Android checks
uses: reactiveCircus/android-emulator-runner@v2
with:
api-level: 29
force-avd-creation: false
arch: x86_64
target: google_apis
profile: Nexus 6
emulator-options: -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim
script: adb shell screencap -p /data/local/tmp/Screenshot.png; adb pull /data/local/tmp/Screenshot.png Screenshot.png;
Are you able to attach the verbose log of the run?
I'm playing around with a dummy repository I have. You can take a look to the run here
Hmmm, one question is do you think if we did this same setup without using reactivecircus's action, that screenshots would be working fine?
Maybe we can alter your demo to do the same thing without this action handling the emulator startup.
I expect they will work as well, any reason why they shouldn't work?
I've also seen people running screenshot tests on headless emulators, I don't think that's an issue. As a reference, this issue (https://github.com/ReactiveCircus/android-emulator-runner/issues/196) is about screenshots, and the emulator options they are using is -no-window
.
@cmonfortep Hey, one of my coworkers had this same issue and said they fixed it by setting this:
sourceCompatibility = 1.8
targetCompatibility = 1.8
https://stackoverflow.com/questions/57838904/emulators-cant-load-libgles-emulation-driver
Thanks @mrk-han. We have that in our app, and on my dummy app for testing.
Let's see if someone could bring more light here about possible issues around screenshots.
@cmonfortep I tried to use the new screenshot APIs and was able to get some output. Had to update to Espresso 3.5.0 Alphas
That's the last thing I can suggest for now.
Make sure to also bring in androidTestUtil "androidx.test.services:test-services:$servicesVersion"
and set testInstrumentationRunnerArguments useTestStorageService: 'true'
in your defaultConfig
Can check this for a sample too https://github.com/android/testing-samples/blob/main/ui/espresso/ScreenshotSample/app/build.gradle
Would change the artifacts to catch the output, and if you want to excplitiyl take a screenshot instead of relying on the default behavior during test failure then can use:
/// in base test
@get:Rule
var nameRule = TestName()
/// then inside your test
takeScreenshot.writeToTestStorage("${javaClass.simpleName}_${nameRule.methodName}_Screenshot") // Takes screenshot of entire page
updated .yml
- name: Upload screenshot
if: always()
uses: actions/upload-artifact@v3
with:
name: device-screenshot
path: |
**/app/build/reports/**
**/app/build/outputs/**
@cmonfortep See: https://github.com/ReactiveCircus/android-emulator-runner/issues/272#issuecomment-1282877350
I don't think this is related to the android-emulator-runner action
Closing because this does not seem related to the android-emulator-runner action. See: https://github.com/ReactiveCircus/android-emulator-runner/issues/272#issuecomment-1282877350
A solution would be appreciated,. check : https://github.com/actions/runner/issues/2287#issuecomment-1350488499
seems like some people succeed to use runner with android emulator
@kopax-polyconseil Using gpu -host
on the Github Hosted macOS Runners shouldn't work. We don't have GPU access
I used to be able to take screenshots with this Action, but now they are mostly coming out blank.
This might be the root case, in case anyone wants to follow: https://github.com/actions/runner-images/issues/6814
Hi,
Try updating to latest Canary version of emulator. I've verified that latest Canary version of emulator no longer has the issue of making blank screenshots. https://github.com/actions/runner-images/issues/6814#issuecomment-1419003014
Also check the Issuetracker issue where I found this fix for more details: https://issuetracker.google.com/issues/259111479#comment3
I'm not familiar with this runner but setting channel
parameter to canary
should pull the Canary version of emulator.