Search code examples
androidjenkinsmulti-configuration

Multi configuration Matrix job fails to start emulator with some errors


I am creating a multi configuration Matrix job to run my tests on multiple emulators on Jenkins but it is failing and emulator does not start. Following is the console output on job:

Building in workspace /Users/mobile_team/.jenkins/multiConfigTestJob/density=480,os=android-28,resolution=1080x1920-13/density/480/os/android-28/resolution/1080x1920
$ /Users/mobile_team/Library/Android/sdk/tools/bin/avdmanager list target
$ /Users/mobile_team/Library/Android/sdk/tools/bin/sdkmanager --list --verbose
Warning: File /Users/mobile_team/.jenkins/multiConfigTestJob/density=480,os=android-28,resolution=1080x1920-13/density/480/os/android-28/resolution/1080x1920/.android/repositories.cfg could not be loaded.
[android] Using Android SDK: /Users/mobile_team/Library/Android/sdk
[android] Creating Android AVD: /Users/mobile_team/.jenkins/multiConfigTestJob/density=480,os=android-28,resolution=1080x1920-13/density/480/os/android-28/resolution/1080x1920/.android/avd/hudson_en-US_480_1080x1920_android-28_google_apis-x86_multiConfigTestJob-density-480-os-android-28-resolution-1080x1920---13.avd
[android] /Users/mobile_team/Library/Android/sdk/tools/bin/avdmanager create avd -f -c 512M -n hudson_en-US_480_1080x1920_android-28_google_apis-x86_multiConfigTestJob-density-480-os-android-28-resolution-1080x1920---13 -k system-images;android-28;google_apis;x86 --tag google_apis
    Loading local repository...                                                     
    [=========                              ] 25% Loading local repository...       
    [=========                              ] 25% Fetch remote repository...        
    [=========                              ] 25% Fetch remote repository...        
    [=========                              ] 25% Fetch remote repository...        
    [=======================================] 100% Fetch remote repository...       
    Auto-selecting single ABI x86
    Do you wish to create a custom hardware profile? [no] 
$ /Users/mobile_team/Library/Android/sdk/platform-tools/adb start-server
* daemon not running; starting now at tcp:5841
* daemon started successfully
$ /Users/mobile_team/Library/Android/sdk/platform-tools/adb start-server
[android] Starting Android emulator
$ /Users/mobile_team/Library/Android/sdk/emulator/emulator -skin 1080x1920 -ports 5696,5697 -report-console tcp:5845,max=60 -prop persist.sys.language=en -prop persist.sys.country=US -avd hudson_en-US_480_1080x1920_android-28_google_apis-x86_multiConfigTestJob-density-480-os-android-28-resolution-1080x1920---13 -wipe-data -noaudio
Refreshing RAM file (size mismatch): existing 0 curr 1610612736
emulator: WARNING: cannot read adb public key file: /Users/mobile_team/.jenkins/multiConfigTestJob/density=480,os=android-28,resolution=1080x1920-13/density/480/os/android-28/resolution/1080x1920/.android/adbkey.pub
qemu-system-x86_64: -drive if=none,index=1,id=cache,file=/Users/mobile_team/.jenkins/multiConfigTestJob/density=480,os=android-28,resolution=1080x1920-13/density/480/os/android-28/resolution/1080x1920/.android/avd/hudson_en-US_480_1080x1920_android-28_google_apis-x86_multiConfigTestJob-density-480-os-android-28-resolution-1080x1920---13.avd/cache.img.qcow2,overlap-check=none,cache=unsafe,l2-cache-size=1048576: Could not open '/Users/mobile_team/.jenkins/multiConfigTestJob/density=480': No such file or directory
[android] Emulator did not appear to start; giving up
[android] Stopping Android emulator
$ /Users/mobile_team/Library/Android/sdk/platform-tools/adb kill-server
Performing Post build task...
Match found for : : True
Logical operation result is TRUE
Skipping post build task 0 - job status is worse than unstable : NOT_BUILT
Archiving artifacts
Finished: NOT_BUILT

Got stuck at this point, not sure what is causing failure... Please help!


Solution

  • Answering the question for others. I figured this way back but forgot to answer. This was happening as Jenkins has an option in configuration under Manage Jenkins > Configure System which is - Keep emulators in the job workspace, in the .android subdirectory, to isolate them as much as possible. If we keep this checked then this error occurs with jobs using multi config matrix.

    enter image description here

    Hope this helps!