title: Gitlab CI emulator not starting
body: <p>I have a problem with the CI on GitLab. It was working before and then, few days ago without changing anything it stopped to work. The emulator doesn't start anymore and the job always finish in timeout. </p>
  
  <p>Here are the logs of the job when it fails (<a href="https://drive.google.com/file/d/1oEReGOMq0lEIIi3BE7KdfjtcR1TUjQ1P/view?usp=sharing" rel="nofollow noreferrer">full log</a>): </p>
  
  <pre><code>[ ... ]
  
  $ wget --quiet --output-document=android-wait-for-emulator https://raw.githubusercontent.com/travis-ci/travis-cookbooks/0f497eb71291b52a703143c5cd63a217c8766dc9/community-cookbooks/android-sdk/files/default/android-wait-for-emulator
  $ chmod +x android-wait-for-emulator
  $ android-sdk-linux/tools/bin/sdkmanager --update &gt; update.log
  Warning: File /root/.android/repositories.cfg could not be loaded.
  $ android-sdk-linux/tools/bin/sdkmanager "platform-tools" "emulator" "system-images;android-${EMULATOR_VERSION};google_apis;x86_64"  &gt; installEmulator.log
  Warning: File /root/.android/repositories.cfg could not be loaded.
  $ echo no | android-sdk-linux/tools/bin/avdmanager create avd --force --name test --abi google_apis/x86_64 --package "system-images;android-${EMULATOR_VERSION};google_apis;x86_64"
  Loading local repository...                                                     
  [=========                              ] 25% Loading local repository...       
  [=========                              ] 25% Fetch remote repository...        
  [=========                              ] 25% Fetch remote repository...        
  [=========                              ] 25% Fetch remote repository...        
  [=======================================] 100% Fetch remote repository...       
  Do you wish to create a custom hardware profile? [no] $ android-sdk-linux/emulator/emulator -avd test -no-window -no-audio &amp;
  $ ./android-wait-for-emulator
  statvfs('/root/.android/avd/test.avd/snapshots/default_boot/ram.img') failed: No such file or directory
  Waiting for emulator to start
  Pulling docker image gitlab/gitlab-runner-helper:x86_64-577f813d ...
  ERROR: Job failed: execution took longer than 1h0m0s seconds
  </code></pre>
  
  <p>Here are the logs of the EXACT SAME job when it worked (<a href="https://drive.google.com/file/d/1uWW1gKa4-JfYnQ6Q-v43mteCJ7Yd5sHG/view?usp=sharing" rel="nofollow noreferrer">full log</a>): </p>
  
  <pre><code>[ ... ]
  
  $ wget --quiet --output-document=android-wait-for-emulator https://raw.githubusercontent.com/travis-ci/travis-cookbooks/0f497eb71291b52a703143c5cd63a217c8766dc9/community-cookbooks/android-sdk/files/default/android-wait-for-emulator
  $ chmod +x android-wait-for-emulator
  $ android-sdk-linux/tools/bin/sdkmanager --update &gt; update.log
  Warning: File /root/.android/repositories.cfg could not be loaded.
  $ android-sdk-linux/tools/bin/sdkmanager "platform-tools" "emulator" "system-images;android-${EMULATOR_VERSION};google_apis;x86_64"  &gt; installEmulator.log
  Warning: File /root/.android/repositories.cfg could not be loaded.
  $ echo no | android-sdk-linux/tools/bin/avdmanager create avd --force --name test --abi google_apis/x86_64 --package "system-images;android-${EMULATOR_VERSION};google_apis;x86_64"
  Loading local repository...                                                     
  [=========                              ] 25% Loading local repository...       
  [=========                              ] 25% Fetch remote repository...        
  [=========                              ] 25% Fetch remote repository...        
  [=========                              ] 25% Fetch remote repository...        
  [=======================================] 100% Fetch remote repository...       
  Do you wish to create a custom hardware profile? [no] $ android-sdk-linux/emulator/emulator -avd test -no-window -no-audio &amp;
  $ ./android-wait-for-emulator
  statvfs('/root/.android/avd/test.avd/snapshots/default_boot/ram.img') failed: No such file or directory
  Waiting for emulator to start
  Your emulator is out of date, please update by launching Android Studio:
   - Start Android Studio
   - Select menu "Tools &gt; Android &gt; SDK Manager"
   - Click "SDK Tools" tab
   - Check "Android Emulator" checkbox
   - Click "OK"
  
  Waiting for emulator to start
  Waiting for emulator to start
  Waiting for emulator to start
  Waiting for emulator to start
  Waiting for emulator to start
  Waiting for emulator to start
  Waiting for emulator to start
  Waiting for emulator to start
  Waiting for emulator to start
  Waiting for emulator to start
  Waiting for emulator to start
  Waiting for emulator to start
  Waiting for emulator to start
  Waiting for emulator to start
  Waiting for emulator to start
  Waiting for emulator to start
  emulator: INFO: boot completed
  emulator: INFO: boot time 23881 ms
  emulator: Increasing screen off timeout, logcat buffer size to 2M.
  emulator: Revoking microphone permissions for Google App.
  Emulator is ready
  $ adb shell settings put global window_animation_scale 0 &amp;
  $ adb shell settings put global transition_animation_scale 0 &amp;
  $ adb shell settings put global animator_duration_scale 0 &amp;
  $ adb shell input keyevent 82
  $ cd ./DenisAppProject
  $ ./gradlew connectedCheck
  
  [ ... ]
  
  $ adb emu kill
  OK: killing emulator, bye bye
  OK
  emulator: Saving state on exit with session uptime 146931 ms
  Job succeeded
  </code></pre>
  
  <p>And here is my gitlab-ci.yml </p>
  
  <pre><code>    image: openjdk:8-jdk
  
      variables:
        ANDROID_COMPILE_SDK: "28"
        ANDROID_BUILD_TOOLS: "28.0.3"
        ANDROID_SDK_TOOLS:   "4333796"
        EMULATOR_VERSION: "26"
  
      before_script:
        - apt-get --quiet update --yes
        - apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1
        - wget --quiet --output-document=android-sdk.zip https://dl.google.com/android/repository/sdk-tools-linux-${ANDROID_SDK_TOOLS}.zip
        - unzip -d android-sdk-linux android-sdk.zip
        - echo y | android-sdk-linux/tools/bin/sdkmanager "platforms;android-${ANDROID_COMPILE_SDK}" &gt;/dev/null
        - echo y | android-sdk-linux/tools/bin/sdkmanager "platform-tools" &gt;/dev/null
        - echo y | android-sdk-linux/tools/bin/sdkmanager "build-tools;${ANDROID_BUILD_TOOLS}" &gt;/dev/null
        - export ANDROID_HOME=$PWD/android-sdk-linux
        - export PATH=$PATH:$PWD/android-sdk-linux/platform-tools/
        - chmod +x ./DenisAppProject/gradlew
        # temporarily disable checking for EPIPE error and use yes to accept all licenses
        - set +o pipefail
        - yes | android-sdk-linux/tools/bin/sdkmanager --licenses
        - set -o pipefail
  
      stages:
        - build
        - unit-test
        - instrumental-test
  
      lintDebug:
        tags: ["android"]
        stage: build
        script:
          - cd DenisAppProject/
          - ./gradlew -Pci --console=plain :DenisApp:lintDebug -PbuildDir=lint
  
      assembleDebug:
        tags: ["android"]
        stage: build
        script:
          - cd DenisAppProject/
          - ./gradlew assembleDebug
        artifacts:
          paths:
          - DenisApp/build/outputs/
  
      debugTests:
        tags: ["android"]
        stage: unit-test
        script:
          - cd DenisAppProject/
          - ./gradlew -Pci --console=plain :DenisApp:testDebug
  
      instrumentation_tests:
        tags: ["android"]
        stage: instrumental-test
        script:
          - apt-get --quiet update --yes
          - apt-get --quiet install --yes libx11-dev libpulse0 libgl1 libnss3 libxcomposite-dev libxcursor1 libasound2
          - wget --quiet --output-document=android-wait-for-emulator https://raw.githubusercontent.com/travis-ci/travis-cookbooks/0f497eb71291b52a703143c5cd63a217c8766dc9/community-cookbooks/android-sdk/files/default/android-wait-for-emulator
          - chmod +x android-wait-for-emulator
          - android-sdk-linux/tools/bin/sdkmanager --update &gt; update.log
          - android-sdk-linux/tools/bin/sdkmanager "platform-tools" "emulator" "system-images;android-${EMULATOR_VERSION};google_apis;x86_64"  &gt; installEmulator.log
          - echo no | android-sdk-linux/tools/bin/avdmanager create avd --force --name test --abi google_apis/x86_64 --package "system-images;android-${EMULATOR_VERSION};google_apis;x86_64"
          - android-sdk-linux/emulator/emulator -avd test -no-window -no-audio &amp;
          - ./android-wait-for-emulator
          # Turn off animations
          - adb shell settings put global window_animation_scale 0 &amp;
          - adb shell settings put global transition_animation_scale 0 &amp;
          - adb shell settings put global animator_duration_scale 0 &amp;
          - adb shell input keyevent 82
          - cd ./DenisAppProject
          - ./gradlew connectedCheck
          - adb emu kill
  </code></pre>
  
  <p>Screen of the job where you can see that it worked the first time and then it stopped (all the jobs before were working). <a href="https://i.stack.imgur.com/kfbpJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kfbpJ.png" alt="Screen"></a></p>