· 7 min read

Run Android Studio's emulator in GitHub Codespaces

  • Free
  • About 30 h a month
  • Android 16
  • No install
  • HTTP API for agents
  • Open source

Yes, the Android emulator runs in GitHub Codespaces. Use a 4-core machine, check that /dev/kvm exists, install the SDK command-line tools and an x86_64 system image, and start the emulator headless. Then stream the screen with scrcpy. Emuly does all of this for you in one prompt, for free.

The short version

  • Machine: 4 cores, 16 GB RAM. The emulator is too slow on 2 cores.
  • Acceleration: KVM. Check that /dev/kvm exists in the codespace.
  • Image: system-images;android-36;google_apis;x86_64 (Android 16)
  • Mode: Headless: no window. You see the screen through scrcpy or a video stream.
  • Cold boot: About 30 to 60 seconds after the first setup
  • Cost: Free within the Codespaces hours of your GitHub plan

1. Pick the machine and check KVM

Create the codespace on the 4-core machine. On 2 cores, Android boots, but apps respond too slowly to test. The 4-core machine also has 16 GB of RAM, so Android can get 8 GB.

Then check for KVM. Without it, the emulator cannot use hardware acceleration.

Check KVM
ls -l /dev/kvm
# If your user cannot open it, give your group access:
sudo chgrp "$(id -gn)" /dev/kvm && sudo chmod 660 /dev/kvm

2. Install the SDK packages

The default codespace image has no Android SDK and misses some libraries that the emulator loads. Install the libraries, then the command-line tools and the packages.

Install the SDK
sudo apt-get update && sudo apt-get install -y libx11-6 libxcomposite1 libxcursor1 \
  libxdamage1 libxi6 libxrandr2 libxtst6 libnss3 libgl1 libegl1 libgbm1 libpulse0 openjdk-21-jre-headless

# After you unpack the command-line tools into $ANDROID_HOME/cmdline-tools/latest:
yes | sdkmanager --licenses
sdkmanager "platform-tools" "emulator" "system-images;android-36;google_apis;x86_64"

The SDK and the image are a few GB. Put them in the persistent home folder, not in /tmp. A codespace clears /tmp when it stops.

3. Create the device and boot it headless

Create and boot
echo no | avdmanager create avd -n phone -k "system-images;android-36;google_apis;x86_64"

emulator -avd phone -no-window -no-boot-anim -no-snapshot \
  -gpu swiftshader -feature -Vulkan -camera-back none -camera-front none &

adb wait-for-device
adb shell 'while [ "$(getprop sys.boot_completed)" != 1 ]; do sleep 1; done'
  • -no-window: A codespace has no display.
  • -gpu swiftshader: Renders the screen on the CPU. A codespace has no GPU.
  • -no-snapshot: Skips the snapshot. Saving one can write 2 GB or more on each stop.
  • RAM: Set hw.ramSize=8192 in the device's config.ini. Apps then stay in memory.

4. See and use the screen

The emulator runs headless, so you need a way to see it. You have two choices:

  • scrcpy from your computer: Forward the adb port from the codespace to your computer, then run scrcpy. You need adb and scrcpy installed locally.
  • A browser stream: Stream the screen as video to a web page. This needs no install on your computer, but you must build or host the streaming server.

Common problems

  • /dev/kvm is missing: The machine type has no KVM. Pick the 4-core machine, or create a new codespace.
  • The emulator exits with library errors: A system library is missing. Install the packages from step 2.
  • Boot takes many minutes: Check KVM, and check that the machine has 4 cores.
  • The codespace stops: GitHub stops an idle codespace after its idle timeout. Raise it to up to 4 hours in your GitHub settings.
  • The SDK is gone after a stop: It was in /tmp. Install it in your home folder or the workspace.

Or let Emuly do every step

Emuly is open source and does exactly the steps above, in your own codespace. It also adds a browser stream, an HTTP API for AI agents, APK installs and screen recording.

  1. Open emuly.xyz and click Copy prompt.
  2. Paste the prompt into your coding agent.
  3. Sign in to GitHub once. The agent creates the codespace and boots the phone.

Want to try it? Start a free phone. It takes one prompt and a GitHub sign-in.