Created
March 18, 2026 12:39
-
-
Save beeman/80715722a8004148cf9491dc496e8a1a to your computer and use it in GitHub Desktop.
Script to create a Pixel 9 Pro Android Emulator with Google Play and 32GB of storage and 8GB of RAM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| set -euo pipefail | |
| ANDROID_SDK_ROOT="${ANDROID_SDK_ROOT:-$HOME/Library/Android/sdk}" | |
| AVDMANAGER="$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/avdmanager" | |
| SDKMANAGER="$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager" | |
| EMULATOR="$ANDROID_SDK_ROOT/emulator/emulator" | |
| AVD_NAME="${AVD_NAME:-Pixel_9_Pro_XL_Play_36}" | |
| DEVICE_ID="${DEVICE_ID:-pixel_9_pro_xl}" | |
| SYSTEM_IMAGE="${SYSTEM_IMAGE:-system-images;android-36;google_apis_playstore;arm64-v8a}" | |
| SYSTEM_IMAGE_DIR="${SYSTEM_IMAGE_DIR:-$ANDROID_SDK_ROOT/system-images/android-36/google_apis_playstore/arm64-v8a}" | |
| DATA_SIZE="${DATA_SIZE:-32G}" | |
| RAM_MB="${RAM_MB:-8192}" | |
| SDCARD_SIZE="${SDCARD_SIZE:-512M}" | |
| VM_HEAP_MB="${VM_HEAP_MB:-576}" | |
| if [ ! -d "$SYSTEM_IMAGE_DIR" ]; then | |
| "$SDKMANAGER" --install "$SYSTEM_IMAGE" | |
| else | |
| echo "Using installed system image: $SYSTEM_IMAGE_DIR" | |
| fi | |
| if "$AVDMANAGER" list avd | grep -q "Name: $AVD_NAME"; then | |
| echo "AVD already exists: $AVD_NAME" | |
| else | |
| echo "no" | "$AVDMANAGER" create avd \ | |
| --abi "arm64-v8a" \ | |
| --device "$DEVICE_ID" \ | |
| --force \ | |
| --name "$AVD_NAME" \ | |
| --package "$SYSTEM_IMAGE" \ | |
| --sdcard "$SDCARD_SIZE" | |
| fi | |
| AVD_DIR="$HOME/.android/avd/$AVD_NAME.avd" | |
| CONFIG_INI="$AVD_DIR/config.ini" | |
| python3 - <<'PY' "$CONFIG_INI" "$AVD_NAME" "$DATA_SIZE" "$RAM_MB" "$SDCARD_SIZE" "$VM_HEAP_MB" | |
| import sys | |
| from pathlib import Path | |
| config_path = Path(sys.argv[1]) | |
| avd_name = sys.argv[2] | |
| data_size = sys.argv[3] | |
| ram_mb = sys.argv[4] | |
| sdcard_size = sys.argv[5] | |
| vm_heap_mb = sys.argv[6] | |
| existing = {} | |
| if config_path.exists(): | |
| for raw in config_path.read_text().splitlines(): | |
| if "=" in raw: | |
| k, v = raw.split("=", 1) | |
| existing[k] = v | |
| existing.update({ | |
| "PlayStore.enabled": "true", | |
| "abi.type": "arm64-v8a", | |
| "avd.ini.displayname": avd_name.replace("_", " "), | |
| "disk.dataPartition.size": data_size, | |
| "fastboot.forceChosenSnapshotBoot": "no", | |
| "fastboot.forceColdBoot": "no", | |
| "fastboot.forceFastBoot": "yes", | |
| "hw.audioInput": "yes", | |
| "hw.camera.back": "virtualscene", | |
| "hw.camera.front": "emulated", | |
| "hw.cpu.arch": "arm64", | |
| "hw.cpu.ncore": "4", | |
| "hw.gpu.enabled": "yes", | |
| "hw.gpu.mode": "auto", | |
| "hw.keyboard": "yes", | |
| "hw.ramSize": ram_mb, | |
| "hw.sdCard": "yes", | |
| "runtime.network.latency": "none", | |
| "runtime.network.speed": "full", | |
| "sdcard.size": sdcard_size, | |
| "showDeviceFrame": "yes", | |
| "skin.dynamic": "yes", | |
| "tag.display": "Google Play", | |
| "tag.displaynames": "Google Play", | |
| "tag.id": "google_apis_playstore", | |
| "tag.ids": "google_apis_playstore", | |
| "userdata.useQcow2": "no", | |
| "vm.heapSize": vm_heap_mb, | |
| }) | |
| config_path.write_text( | |
| "\n".join(f"{k}={existing[k]}" for k in sorted(existing)) + "\n" | |
| ) | |
| PY | |
| echo | |
| echo "Created AVD: $AVD_NAME" | |
| echo "Launch with:" | |
| echo "\"$EMULATOR\" @\"$AVD_NAME\"" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment