Android Emulator is failing on macOS: Could not open GL library libGLESv2.dylib

#1

I am getting the following when launching the android emulator on macOS:

#!/bin/bash --login -eo pipefail
/usr/local/share/android-sdk/tools/emulator @Pixel_2_API_26 -skin 1080x2066 -memory 2048 -noaudio

^D^Demulator: WARNING: userdata partition is resized from 550 M to 800 M

emulator: WARNING: Your GPU drivers may have a bug. Switching to software rendering.
EglOsGlLibrary: Could not open GL library libGLESv2.dylib [dlopen(libGLESv2.dylib, 2): image not found]
EglOsEglDispatcher: Could not open EGL library libEGL.dylib [dlopen(libEGL.dylib, 2): image not found]
Exited with code 1

This is my config:

version: 2
reference:
  ## Constants
  gradle_cache_path: &gradle_cache_path
                       gradle_cache-{{ checksum "build.gradle" }}-{{ checksum  "app/build.gradle" }}
  workspace: &workspace
               ~/src
  ## Configurations
  android_config: &android_config
    working_directory: *workspace
    macos:
      xcode: "9.4.0"
    shell: /bin/bash --login -eo pipefail
    environment:
      TERM: dumb
      JVM_OPTS: -Xmx3200m
  ## Cache
  restore_gradle_cache: &restore_gradle_cache
    restore_cache:
      key: *gradle_cache_path
  save_gradle_cache: &save_gradle_cache
    save_cache:
      key: *gradle_cache_path
      paths:
        - ~/.gradle

  ## Dependency Downloads
  download_android_dependencies: &download_android_dependencies
    run:
      name: Download Android Dependencies
      command: ./gradlew androidDependencie

jobs:
  build:
    <<: *android_config
    steps:
      - checkout
      - run:
          name: Setup environment variables
          command: |
            echo 'export PATH="$PATH:/usr/local/opt/node@8/bin:${HOME}/.yarn/bin:${HOME}/${CIRCLE_PROJECT_REPONAME}/node_modules/.bin:/usr/local/share/android-sdk/tools/bin"' >> $BASH_ENV
            echo 'export ANDROID_HOME="/usr/local/share/android-sdk"' >> $BASH_ENV
            echo 'export ANDROID_SDK_HOME="/usr/local/share/android-sdk"' >> $BASH_ENV
            echo 'export ANDROID_SDK_ROOT="/usr/local/share/android-sdk"' >> $BASH_ENV
            echo 'export QEMU_AUDIO_DRV=none' >> $BASH_ENV
            echo 'export JAVA_HOME=/Library/Java/Home' >> $BASH_ENV
      - run:
          name: Install Android sdk
          command: |
            HOMEBREW_NO_AUTO_UPDATE=1 brew tap homebrew/cask
            HOMEBREW_NO_AUTO_UPDATE=1 brew cask install android-sdk
      - run:
          name: Install emulator dependencies
          command: (yes | sdkmanager "platform-tools" "platforms;android-26" "extras;intel;Hardware_Accelerated_Execution_Manager" "build-tools;26.0.0" "system-images;android-26;google_apis;x86" "emulator" --verbose) || true
      - *restore_gradle_cache
      - *download_android_dependencies
      - *save_gradle_cache
      - run: avdmanager create avd -n Pixel_2_API_26 -k "system-images;android-26;google_apis;x86" -g google_apis -d "Nexus 5"
      - run:
          name: Run emulator in background
          command: /usr/local/share/android-sdk/tools/emulator @Pixel_2_API_26 -skin 1080x2066 -memory 2048 -noaudio
          background: true
      - run:
          name: Run Tests
          command: ./gradlew app:connectedAndroidTest