android-emulator-runner icon indicating copy to clipboard operation
android-emulator-runner copied to clipboard

Emulator randomly not booting

Open chrisbanes opened this issue 4 years ago β€’ 5 comments

I've been seeing a lot of flakiness lately in the emulator booting, across many different API levels.

The common thing between the failures seems to be Warning: An error occurred while preparing SDK package XXX System Image: archive is not a ZIP archive.. Looks like the sdkmanager --install call is failing (network error?)

Full log

2021-09-29T06:20:44.8879740Z [command]/bin/sh -c \yes | sdkmanager --licenses > /dev/null
2021-09-29T06:20:48.2758470Z Warning: Observed package id 'ndk;21.4.7075529' in inconsistent location '/Users/runner/Library/Android/sdk/ndk-bundle' (Expected '/Users/runner/Library/Android/sdk/ndk/21.4.7075529')
2021-09-29T06:20:48.7616530Z Warning: Observed package id 'ndk;21.4.7075529' in inconsistent location '/Users/runner/Library/Android/sdk/ndk-bundle' (Expected '/Users/runner/Library/Android/sdk/ndk/21.4.7075529')
2021-09-29T06:20:50.6501660Z Installing latest build tools, platform tools, and platform.
2021-09-29T06:20:50.6548180Z [command]/bin/sh -c \sdkmanager --install 'build-tools;31.0.0' platform-tools 'platforms;android-29' > /dev/null
2021-09-29T06:20:52.3046800Z Warning: Observed package id 'ndk;21.4.7075529' in inconsistent location '/Users/runner/Library/Android/sdk/ndk-bundle' (Expected '/Users/runner/Library/Android/sdk/ndk/21.4.7075529')
2021-09-29T06:20:52.8468490Z Warning: Observed package id 'ndk;21.4.7075529' in inconsistent location '/Users/runner/Library/Android/sdk/ndk-bundle' (Expected '/Users/runner/Library/Android/sdk/ndk/21.4.7075529')
2021-09-29T06:20:53.8165190Z Installing latest emulator.
2021-09-29T06:20:53.8212810Z [command]/bin/sh -c \sdkmanager --install emulator --channel=0 > /dev/null
2021-09-29T06:20:55.5486370Z Warning: Observed package id 'ndk;21.4.7075529' in inconsistent location '/Users/runner/Library/Android/sdk/ndk-bundle' (Expected '/Users/runner/Library/Android/sdk/ndk/21.4.7075529')
2021-09-29T06:20:56.1727590Z Warning: Observed package id 'ndk;21.4.7075529' in inconsistent location '/Users/runner/Library/Android/sdk/ndk-bundle' (Expected '/Users/runner/Library/Android/sdk/ndk/21.4.7075529')
2021-09-29T06:20:56.8878320Z Installing emulator build 7425822.
2021-09-29T06:20:56.8989860Z [command]/usr/local/opt/curl/bin/curl -fo emulator.zip https://dl.google.com/android/repository/emulator-darwin_x64-7425822.zip
2021-09-29T06:20:56.9647350Z   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
2021-09-29T06:20:56.9664940Z                                  Dload  Upload   Total   Spent    Left  Speed
2021-09-29T06:20:56.9666890Z 
2021-09-29T06:20:57.4378380Z   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
2021-09-29T06:20:58.4387800Z   8  294M    8 24.6M    0     0  50.5M      0  0:00:05 --:--:--  0:00:05 51.9M
2021-09-29T06:21:00.1945760Z  35  294M   35  103M    0     0  69.4M      0  0:00:04  0:00:01  0:00:03 70.0M
2021-09-29T06:21:00.4378350Z  61  294M   61  180M    0     0  55.6M      0  0:00:05  0:00:03  0:00:02 55.8M
2021-09-29T06:21:01.3120480Z  68  294M   68  201M    0     0  57.9M      0  0:00:05  0:00:03  0:00:02 58.1M
2021-09-29T06:21:01.3122520Z 100  294M  100  294M    0     0  67.5M      0  0:00:04  0:00:04 --:--:-- 67.7M
2021-09-29T06:21:01.3335870Z [command]/usr/bin/unzip -o -q emulator.zip -d /Users/runner/Library/Android/sdk
2021-09-29T06:21:08.2735870Z Installing system images.
2021-09-29T06:21:08.2782340Z [command]/bin/sh -c \sdkmanager --install 'system-images;android-29;google_apis;x86' --channel=0 > /dev/null
2021-09-29T06:21:10.2918080Z Warning: Observed package id 'ndk;21.4.7075529' in inconsistent location '/Users/runner/Library/Android/sdk/ndk-bundle' (Expected '/Users/runner/Library/Android/sdk/ndk/21.4.7075529')
2021-09-29T06:21:10.7233530Z Warning: Observed package id 'ndk;21.4.7075529' in inconsistent location '/Users/runner/Library/Android/sdk/ndk-bundle' (Expected '/Users/runner/Library/Android/sdk/ndk/21.4.7075529')
2021-09-29T06:25:27.6883990Z Warning: An error occurred while preparing SDK package Google APIs Intel x86 Atom System Image: archive is not a ZIP archive.
2021-09-29T06:25:27.7104260Z [command]/Users/runner/Library/Android/sdk/platform-tools/adb -s emulator-5554 emu kill
2021-09-29T06:25:27.9295620Z error: could not connect to TCP port 5554: Connection refused
2021-09-29T06:25:27.9322250Z The process '/Users/runner/Library/Android/sdk/platform-tools/adb' failed with exit code 1
2021-09-29T06:25:27.9335620Z ##[error]The process '/bin/sh' failed with exit code 1

chrisbanes avatar Sep 29 '21 08:09 chrisbanes

I'm surprised how people are not losing their hair by how flaky those emulators are πŸ˜‚

lucas-zimerman avatar Nov 29 '21 15:11 lucas-zimerman

I'm surprised how people are not losing their hair by how flaky those emulators are πŸ˜‚

They areπŸ˜„

ychescale9 avatar Nov 29 '21 17:11 ychescale9

So this can happen out of the blue for no reason? No way to overcome that?

JJ avatar Mar 07 '22 08:03 JJ

This has bitten me a few times. It's a transient error, and a more robust system (that still acknowledges transient network errors may happen) would have a configurable number of retries with configurable delay before hard-failing.

For instance, this works really well for retrying: https://github.com/nick-fields/retry

All access to remote resources should be wrapped in similar logic really Emulator boot could similar be wrapped with logic to retry a configurable number of times after a configurable amount of delay waiting for the "booted" adb response

Is there any appetite for a PR that would implement these sort of robust-ness workarounds? I wanted to move to this action to simplify my scripts, but I used to have them in place when doing what this action does (but manually) in my workflows, and the flakiness is a pain vs my more-complicated-but-more-robust manual way

mikehardy avatar Jun 02 '22 15:06 mikehardy

PR Request: Wrap emulator boot logic in a configurable loop, defaults to a certain number.

mrk-han avatar Oct 20 '22 18:10 mrk-han