-
-
Save brodybits/74c30d2c409270cbb0eb45225ed5bd41 to your computer and use it in GitHub Desktop.
Android Emulator with Homebrew
This file contains 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
# Recommended prerequisites: | |
# - Xcode is installed | |
# - Homebrew is installed - I am using a custom subdirectory as described in: | |
# - https://superuser.com/questions/1336025/how-should-i-install-homebrew-into-usr-local-subdirectory-manually | |
# - OpenJDK 8 is installed - here are a couple recommended resources: | |
# - https://apple.stackexchange.com/questions/349465/how-can-i-upgrade-from-oracle-jdk-8-to-openjdk-8-using-homebrew | |
# - https://dzone.com/articles/install-openjdk-versions-on-the-mac - good but shows formulae that I did not see | |
# - brew doctor does not show any issues | |
# I think this is not needed any more: | |
# touch ~/.android/repositories.cfg | |
# PART 1 - Android SDK package: | |
brew cask install android-sdk | |
# the output shows an export command that should be saved in the user profile, | |
# for example: | |
# | |
# export ANDROID_SDK_ROOT="/usr/local/share/android-sdk" | |
# | |
# (I think the double quotes are not really needed) | |
# | |
# then it is recommended to source the profile or start a new shell. | |
# try the following command: | |
sdkmanager | |
# (it would show that ~/.android/repositories.cfg is needed) | |
touch ~/.android/repositories.cfg | |
# then sdkmanager should be ok (does not seem to do much) | |
# PART 2 - Intel HAXM (accelerator): | |
# This step would likely need sudo permission from the user | |
# and possibly extra permission from the security manager | |
# (I got a dialog that allowed me to do this from | |
# System Preferences): | |
brew cask install intel-haxm | |
# NOT NEEDED: | |
# brew install qt | |
# PART 3 - add (install) an emulator from the command line: | |
# It is recommended to do the following command in the profile (as described above) | |
# (ADJUST the following path if needed; not sure if double-quotes are needed or not): | |
# export ANDROID_SDK_ROOT="/usr/local/share/android-sdk" | |
# This sdkmanager command seems to show prompts to accept license agreements: | |
sdkmanager "platform-tools" "platforms;android-27" "extras;intel;Hardware_Accelerated_Execution_Manager" "build-tools;27.0.0" "system-images;android-27;google_apis;x86" "emulator" | |
avdmanager create avd -n test -k "system-images;android-27;google_apis;x86" | |
# to check that the AVD was created: | |
avdmanager list avd | |
# or ls ~/.android/avd | |
# PART 4 - run the emulator from the command line: | |
# Update the PATH | |
# (It is recommended to add it to the profile then source it | |
# or start a new shell session): | |
export PATH=$ANDROID_SDK_ROOT/emulator:$ANDROID_SDK_ROOT/tools:$ANDROID_SDK_ROOT/platform-tools:$PATH | |
# The following command seems to run in the foreground | |
# with a few pitfalls below | |
emulator -avd test | |
# some emulator pitfalls: | |
# * possible unidentified developer issue starting with macOS Catalina, see | |
# https://support.apple.com/guide/mac-help/open-a-mac-app-from-an-unidentified-developer-mh40616/mac | |
# * It may be needed to use the absolute path to emulator on some older Android SDK versions. | |
# Next steps: | |
# Install some build tools, android-ndk, and try running from | |
# an IDE such as IntelliJ. | |
# Some references: | |
# - https://stackoverflow.com/questions/26483370/android-emulator-error-message-panic-missing-emulator-engine-program-for-x86 | |
# - https://developer.android.com/studio/run/emulator-commandline |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment