Instantly share code, notes, and snippets.

Embed
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 https://raw.github.com/Homebrew/homebrew/go/install)"

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: http://developer.android.com/tools/devices/emulator.html

brew cask install intel-haxm // this might not work on high sierra.

Edit: You can download the dmg and install manually from Intel's site

Finally 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=$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/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

This comment has been minimized.

Copy link
Owner Author

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

tonejac commented Dec 21, 2017

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

Thanks for putting this together. Solid info!!

@schutzsmith

This comment has been minimized.

Copy link

schutzsmith commented Dec 23, 2017

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

Thanks for the updated instructions!

@agrcrobles

This comment has been minimized.

Copy link
Owner Author

agrcrobles commented Dec 27, 2017

updated, thanks for the feedback guys

@bramus

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

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!

@nitin7dc

This comment has been minimized.

Copy link

nitin7dc commented Jan 12, 2018

thanks 👍

@vsviridov

This comment has been minimized.

Copy link

vsviridov commented Jan 31, 2018

Java9 Workaround (put in the .profile or similar)

export SDKMANAGER_OPTS="-XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee"
@stevestock

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

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
@Cassidamius

This comment has been minimized.

Copy link

Cassidamius commented Feb 22, 2018

Thanks for the instructions! As @AceLondon mentioned above, there's a problem on High Sierra (macOS version 10.13.x).
brew cask install intel-haxm doesn't work
==> Verifying checksum for Cask intel-haxm ==> Installing Cask intel-haxm ==> Running installer script 'silent_install.sh' **==> HAXM silent installation only supports macOS from 10.8 to 10.12 !** ==> Purging files for version 6.2.1,a0:49 of Cask intel-haxm Error: Command failed to execute!

You can download the dmg and install manually from Intel's site:
https://software.intel.com/en-us/android/articles/installation-instructions-for-intel-hardware-accelerated-execution-manager-mac-os-x

@emanueleDiVizio

This comment has been minimized.

Copy link

emanueleDiVizio commented Jul 9, 2018

Quick update, ruby command to install homebrew doesn't seem to be working. Here's the command from homebrew website.

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

@jasonnmark

This comment has been minimized.

Copy link

jasonnmark commented Jan 27, 2019

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

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