Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Setup 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"

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

brew doctor
brew tap caskroom/cask

Install Python 3: brew install python3

Use Homebrew to install Android dev tools:

brew install ant
brew install maven
brew install gradle
brew cask install android-sdk
brew cask 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):

sdkmanager "platform-tools" "platforms;android-23"
sdkmanager "build-tools;23.0.1"

Install HAXM for blazing fast emulators. Check out the "Configuring VM Acceleration on Mac" section here:

brew cask install intel-haxm

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/share/android-sdk
export ANDROID_NDK_HOME=/usr/local/share/android-ndk
export INTEL_HAXM_HOME=/usr/local/Caskroom/intel-haxm

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

export PATH=$ANT_HOME/bin:$PATH
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/build-tools/23.0.1:$PATH

Optional: You will have to add the ANDROID_HOME to the profile configuration settings either on .zshrc, .bashrc or .bash_profile ( suggested )


agrcrobles commented Nov 28, 2017

  Path               | Version | Description                    | Location           
  -------            | ------- | -------                        | -------            
  build-tools;26.0.2 | 26.0.2  | Android SDK Build-Tools 26.0.2 | build-tools/26.0.2/
  emulator           | 26.1.4  | Android Emulator               | emulator/          
  patcher;v4         | 1       | SDK Patch Applier v4           | patcher/v4/        
  platform-tools     | 26.0.2  | Android SDK Platform-Tools     | platform-tools/    
  tools              | 26.1.1  | Android SDK Tools              | tools/             

tonejac commented Dec 20, 2017

Is that correct with the line:
sdkmanager --install "build-tools;23.0.1"

Couldn't get that one to work. Says "Warning: Unknown argument --install".

tonejac commented Dec 21, 2017

I took out the --install flag and it worked great.

Thanks for putting this together. Solid info!!

Same here, removing the --install flag worked like a charm.

Thanks for the updated instructions!


agrcrobles commented Dec 27, 2017

updated, thanks for the feedback guys

bramus commented Jan 5, 2018

When starting fresh off, you'll also need to install Java. Note that version 9 won't work, so you'll have to specifically target version 8:

brew cask install caskroom/versions/java8

AceLondon commented Jan 8, 2018

Just putting it out there but HAXM install does not support the newest version of macOS - I'm currently on 10.13.2:

==> Standard Output of failed command: HAXM silent installation only supports macOS from 10.8 to 10.12 !

Thanks for the instructions! Beautifully curated!

thanks 👍

Java9 Workaround (put in the .profile or similar)

export SDKMANAGER_OPTS="-XX:+IgnoreUnrecognizedVMOptions --add-modules"

stevestock commented Feb 3, 2018

brew cask install android-sdkautomatically installs java 8
see the android-sdk cask

EDIT: never mind, i misunderstood, brew cask only states the dependency, doesn't automatically install it

mbunge commented Feb 13, 2018

I ended up uninstalling JDK9 and installing Java SE Development Kit 8u144. Hope this helps. I also need to android-ndk and android-sdk and follow these stepps

brew cask uninstall android-ndk # Only of installed and ran in to error!
brew cask uninstall android-sdk # Only of installed and ran in to error!
brew cask uninstall java # uninstall java9
brew tap caskroom/versions
brew cask install java8
touch ~/.android/repositories.cfg # without this file, error will occur on next step
brew cask install android-sdk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment