Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save ckarthickit2/172a56fd211e9217e9bc039977b36da1 to your computer and use it in GitHub Desktop.

Select an option

Save ckarthickit2/172a56fd211e9217e9bc039977b36da1 to your computer and use it in GitHub Desktop.
Easily setup an Android development environment on a Mac

Here is a high level overview for what you need to do to get most of an Android environment setup and maintained.

Prerequisites (for Homebrew at a minimum, lots of other tools need these too):

  • XCode is installed (via the App Store)
  • XCode command line tools are installed (xcode-select --install will prompt up a dialog)
  • Java

Install Homebrew:

ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

Make sure the doctor is happy (do what it tells you):

brew doctor

Use Homebrew to install Android dev tools:

brew install ant
brew install maven
brew install gradle
brew install android-sdk
brew install android-ndk

Install all of the Android SDK components (you will be prompted to agree to license info and then this will take a while to run):

android update sdk --no-ui

Install HAXM for blazing fast emulators. Check out the "Configuring VM Acceleration on Mac" section here: http://developer.android.com/tools/devices/emulator.html

Update your environment variables:

export ANT_HOME=/usr/local/opt/ant
export MAVEN_HOME=/usr/local/opt/maven
export GRADLE_HOME=/usr/local/opt/gradle
export ANDROID_HOME=/usr/local/opt/android-sdk
export ANDROID_NDK_HOME=/usr/local/opt/android-ndk

Update your paths (bonus points to a better solution to the hardcoded build tools version):

export PATH=$ANT_HOME/bin:$PATH
export PATH=$MAVEN_HOME/bin:$PATH
export PATH=$GRADLE_HOME/bin:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/build-tools/19.1.0:$PATH

Periodically run these commands again to ensure you're staying up to date:

brew update
android update sdk --no-ui
  • Note: It looks like there might be an issue with brew update and the android-sdk formula.

Install Eclipse, IntelliJ, Android Studio, or your other favorite IDE.

If everything goes smoothly on a moderate network connection you can expect this process to take 2-4 hours.

@ckarthickit2
Copy link
Author

mac:~ user$ brew cask install android-sdk
==> Caveats
You can control android sdk packages via the sdkmanager command.
You may want to add to your profile:

'export ANDROID_SDK_ROOT="/usr/local/share/android-sdk"'

android-sdk requires Java 8. You can install it with:
brew cask install homebrew/cask-versions/adoptopenjdk8

==> Downloading https://dl.google.com/android/repository/sdk-tools-darwin-4333796.zip
Already downloaded: /Users/macbuilder/Library/Caches/Homebrew/downloads/b556e94e3ceec88e3a4a87181361c20aae8ca8f45513c021e132c372cafc5258--sdk-tools-darwin-4333796.zip
==> Verifying SHA-256 checksum for Cask 'android-sdk'.
==> Installing Cask android-sdk
==> Linking Binary 'android' to '/usr/local/bin/android'.
==> Linking Binary 'archquery' to '/usr/local/bin/archquery'.
==> Linking Binary 'avdmanager' to '/usr/local/bin/avdmanager'.
==> Linking Binary 'jobb' to '/usr/local/bin/jobb'.
==> Linking Binary 'lint' to '/usr/local/bin/lint'.
==> Linking Binary 'monkeyrunner' to '/usr/local/bin/monkeyrunner'.
==> Linking Binary 'screenshot2' to '/usr/local/bin/screenshot2'.
==> Linking Binary 'sdkmanager' to '/usr/local/bin/sdkmanager'.
==> Linking Binary 'uiautomatorviewer' to '/usr/local/bin/uiautomatorviewer'.
==> Linking Binary 'emulator' to '/usr/local/bin/emulator'.
==> Linking Binary 'emulator-check' to '/usr/local/bin/emulator-check'.
==> Linking Binary 'mksdcard' to '/usr/local/bin/mksdcard'.
==> Linking Binary 'monitor' to '/usr/local/bin/monitor'.
🍺 android-sdk was successfully installed!
mac:~ user$ brew cask install android-ndk
==> Caveats
You may want to add to your profile:
'export ANDROID_NDK_HOME="/usr/local/share/android-ndk"'

==> Downloading https://dl.google.com/android/repository/android-ndk-r21-darwin-x86_64.zip
######################################################################## 100.0%
==> Verifying SHA-256 checksum for Cask 'android-ndk'.
==> Installing Cask android-ndk
==> Linking Binary 'ndk_exec.sh' to '/usr/local/bin/ndk-build'.
==> Linking Binary 'ndk_exec.sh' to '/usr/local/bin/ndk-depends'.
==> Linking Binary 'ndk_exec.sh' to '/usr/local/bin/ndk-gdb'.
==> Linking Binary 'ndk_exec.sh' to '/usr/local/bin/ndk-stack'.
==> Linking Binary 'ndk_exec.sh' to '/usr/local/bin/ndk-which'.
🍺 android-ndk was successfully installed!
mac:~ user$

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