Skip to content

Instantly share code, notes, and snippets.

@fionn
Created October 7, 2020 08:28
Show Gist options
  • Save fionn/16f3101051208d5c3ad54e4879f973a4 to your computer and use it in GitHub Desktop.
Save fionn/16f3101051208d5c3ad54e4879f973a4 to your computer and use it in GitHub Desktop.
Android emulation on Darwin

Get the Android SDK with brew cask install android-sdk. It has a Java 8 dependency and tells you to install it with brew cask install homebrew/cask-versions/adoptopenjdk8. If you already have another newer version, you must set JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home.

You now have emulator, sdkmanager and avdmanager.

To save yourself the missing file warnings, touch .android/repositories.cfg.

To make a test VM, run sdkmanager "system-images;android-30;google_apis;x86" to get the base image. You'll have to accept some licenses. Then avdmanager create avd -n $base -k "system-images;android-30;google_apis;x86" to add it to the device list as $base.

From now on, setting ANDROID_EMULATOR_DEBUG=1 will be useful. You'll also need to set ANDROID_SDK_ROOT=/usr/local/share/android-sdk.

Get the SDK's platform tools with sdkmanager "platform-tools" "platforms;android-30".

Then run the emulator. If you run it with emulator, it will fail in an opaique way. Instead of running the version in $PATH (shpuld be /usr/local/bin/emulator), you must instead run $ANDROID_SDK_ROOT/emulator/emulator. Call it with -avd $base and it will load up QEMU and run your device.

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