Note on Ionic framework: Android platform in OS X
In this blog post, we are going to walk through a couple of error messages to install dependencies for Android platform of Ionic framework using Mac OS X. Follow this official guide to install Cordova and ionic, then create project until the step to config platform.
We want to enable the Android platform by this command:
ionic platform add android
But you may encounter this error:
Error: ANDROID_HOME is not set and "android" command not in your PATH.
Step 1: Download android-sdk
Go to the android developer website and download stand-alone SDK Tools: https://developer.android.com/sdk/installing/index.html
Step 2: Unzip the file
For example, I unzip it to the path of my workspace
/Users/Victor/Workspace/android-sdk-macosx
Step 3: Set android command in your PATH
Note: replace my name “Victor” below to your name. In case you are using on-my-zsh, replace the command from bash to zsh profile.
- In your terminal, make sure we have a newline at the end of the .bash_profile
echo >> /Users/Victor/.bash_profile
- Set the ANDROID HOME value in the .bash_profile
echo "export ANDROID_HOME=/Users/Victor/Workspace/android-sdk-macosx" >> /Users/Victor/.bash_profile
- Alter the PATH value a bit as well
echo "export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools" >> /Users/Victor/.bash_profile
- Tell the terminal to update all the things
. /Users/Victor/.bash_profile
Step 4: Install android-19
Now if you try again to run:
ionic platform add android
You may come up with 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). Then click “install 8 packages…”.
Accepted the license. And finger crossed while waiting for the download process.
Finally, try this command again:
ionic platform add android
And boom,
Project successfully created.
Feel free to send me a help request if you couldn’t get it working. Cheers☺
Originally published at victorleungtw.com on December 22, 2014.