Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vadimszzz/46eda1872f7b8c1f3b14674327fe099c to your computer and use it in GitHub Desktop.
Save vadimszzz/46eda1872f7b8c1f3b14674327fe099c to your computer and use it in GitHub Desktop.

How to run Android Studio Emulator (AVD) without lags

Running ARMv7/ARM64 image on x86_64 host with maximum emulation performance:

  1. Close all Google Chrome instances and shutdown your antivirus.

  2. Better create ARMv7 image without Google APIs.

  3. Fix "cannot add library /usr/local/android-sdk/emulator/qemu/darwin-x86_64/lib64/vulkan/libvulkan.dylib: failed":
    λ ln -s ${ANDROID_SDK_ROOT}/emulator/lib64 ${ANDROID_SDK_ROOT}/emulator/qemu/darwin-x86_64/lib64

  4. λ ${ANDROID_SDK_ROOT}/emulator/emulator @NAME -no-snapshot -no-boot-anim -gpu host -qemu -icount auto -smp 4,sockets=1,cores=2,threads=2,maxcpus=4

    maxcpus must be a half of your real CPU cores for the best performance but i usually set all 4
    sockets * cores * threads must be not greater than maxcpus
    smp must be not greater than maxcpus

  5. You should wait for 15-60 minutes even if you have the latest MacBook Pro.

  6. After successful booting press ... button, Snapshots, Take snapshot. It will save your time if something goes wrong. To start the emulator next time use the same command without -no-snapshot option:
    λ ${ANDROID_SDK_ROOT}/emulator/emulator @NAME -no-boot-anim -gpu host -qemu -icount auto -smp 4,sockets=1,cores=2,threads=2,maxcpus=4

Running x86/x86_64 image on x86_64 host with maximum emulation performance:

  1. Install Intel HAXM.

  2. Fix "cannot add library /usr/local/android-sdk/emulator/qemu/darwin-x86_64/lib64/vulkan/libvulkan.dylib: failed":
    λ ln -s ${ANDROID_SDK_ROOT}/emulator/lib64 ${ANDROID_SDK_ROOT}/emulator/qemu/darwin-x86_64/lib64

  3. λ ${ANDROID_SDK_ROOT}/emulator/emulator @NAME -no-boot-anim -gpu host -qemu -smp 4,sockets=1,cores=2,threads=2,maxcpus=4

    maxcpus must be a half of your real CPU cores for the best performance but i usually set all 4
    sockets * cores * threads must be not greater than maxcpus
    smp must be not greater than maxcpus

More information: https://developer.android.com/studio/run/emulator-acceleration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment