Skip to content

Instantly share code, notes, and snippets.

@pqnga
Forked from agrcrobles/android_instructions_29.md
Last active September 25, 2019 04:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pqnga/1a947b385e5a72d88cb22642fb62992a to your computer and use it in GitHub Desktop.
Save pqnga/1a947b385e5a72d88cb22642fb62992a to your computer and use it in GitHub Desktop.
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: Note that Java8 is tricky since licence changed: https://stackoverflow.com/questions/24342886/how-to-install-java-8-on-mac

brew install ant
brew install maven
brew install gradle
brew cask install android-sdk
brew cask install android-ndk
brew cask install adoptopenjdk/openjdk/adoptopenjdk8

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):

touch ~/.android/repositories.cfg
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

Install emulators? Nga copied from https://gist.github.com/gasolin/9300f5f9276b2df884c80da3e2c54ffc

sdkmanager --no_https --install emulator
sdkmanager --no_https --install platform-tools
sdkmanager --no_https --install 'system-images;android-29;google_apis_playstore;x86_64'
sdkmanager --no_https --install 'extras;intel;Hardware_Accelerated_Execution_Manager'
sdkmanager --update
sdkmanager --list

Create and run virtual devices? Nga copied from https://gist.github.com/gasolin/9300f5f9276b2df884c80da3e2c54ffc

avdmanager list (find device skin id, lets use pixel 17)
avdmanager create avd -f -n test -d 17 -k 'system-images;android-29;google_apis_playstore;x86_64'
avdmanager list avd (or emulator -list-avds)

/usr/local/share/android-sdk/emulator/emulator -avd test

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_SDK_ROOT=/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 )

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