In this blog post, we will walk through several error messages that you might encounter when installing dependencies for the Android platform of the Ionic framework on Mac OS X. Follow this official guide to install Cordova and Ionic, and then create a project up until the step where you configure the platform.

To enable the Android platform, run the following command:

ionic platform add android

However, you may encounter this error:

Error: ANDROID_HOME is not set and "android" command not in your PATH.

Step 1: Download the Android SDK

Visit the Android developer website and download the stand-alone SDK Tools: https://developer.android.com/sdk/installing/index.html.

Step 2: Unzip the File

I unzipped the SDK to the path of my workspace:

/Users/Victor/Workspace/android-sdk-macosx

Step 3: Set the Android Command in Your PATH

Note: Replace “Victor” with your username. If you are using oh-my-zsh, replace the .bash_profile with your .zshrc profile.

  1. Open your terminal and ensure that .bash_profile ends with a newline:
echo >> /Users/Victor/.bash_profile
  1. Set the ANDROID_HOME environment variable in .bash_profile:
echo "export ANDROID_HOME=/Users/Victor/Workspace/android-sdk-macosx" >> /Users/Victor/.bash_profile
  1. Update the PATH variable as well:
echo "export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools" >> /Users/Victor/.bash_profile
  1. Reload the terminal to apply the changes:
. /Users/Victor/.bash_profile

Step 4: Install Android-19

Now, if you try to run:

ionic platform add android

You might see the following error:

Error: Please install Android target "android-19".

Run android from your command line to open the SDK manager:

android

Check the box for Android 4.4.2 (API 19) and then click “Install 8 packages…”. Accept the license and keep your fingers crossed while waiting for the download process to complete.

Finally, try running the command again:

ionic platform add android

And voila:

Project successfully created.

If you encounter any issues, feel free to send me a help request. Cheers! ☺