Install the Android SDK through Homebrew:
brew update && brew install android-sdk
Add the $ANDROID_SDK_ROOT
to your shell. By default OS X uses bash. r24.0.1
is the latest version at the time of writing this. This might differ for you. Check brew’s installation output. It has the correct export line in it.
The following command should take care of it:
echo "export ANDROID_SDK_ROOT=/usr/local/Cellar/android-sdk/r20.0.1" >> ~/.bash_profile && source ~/.bash_profile
Next step is to install the version of android we want to use. Android calls these ‘targets’. At all times you can see what’s installed and install new things for the android SDK using the following command:
android update sdk
I chose to install everything from 4.1. Installing is easy. Just follow the wizard. Sidenote: the Google APIs failed to install for me. The second time as well and somehow it is still marked as installed. Slightly troubling but the emulation still works.
If everything is done it should look like this: android SDK update window
Every ‘Android Virtual Device’ (AVD) you make needs to be linked with an android version (target) and is referenced by a name. So let’s figure out the ID.
android list targets
Available Android targets:
----------
id: 1 or "android-16"
Name: Android 4.1
Type: Platform
API level: 16
Revision: 2
Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
ABIs : armeabi-v7a
As you can see mine is simply ‘1’. Yours might differ so be sure to check it for yourself.
Creating a device is simple:
android create avd -n hshmrk -t 1
Auto-selecting single ABI armeabi-v7a
Android 4.1 is a basic Android platform.
Do you wish to create a custom hardware profile [no]no
Created AVD 'hshmrk' based on Android 4.1, ARM (armeabi-v7a) processor,
with the following hardware config:
hw.lcd.density=240
vm.heapSize=48
hw.ramSize=512
-n is the name. You’ll probably want to change that. -t is the target ID. I chose to go with the default hardware profile. I’m guessing you can tweak it to make your device more like a tablet or something with a beefier core. By default it emulates as your average android phone.
The next command you’ll be using a lot. It’s the one used to start your device.
emulator -avd hshmrk
Smoooth! Couldn’t be simpler. Just remember to use the correct AVD name.