Android Emulator on Mac
January 14, 2015
I am happy to report that Android Studio for Mac is easier to configure and faster than the previous Android Emulator. I only care about the emulator portion of the studio, so with that in mind, here is what worked for me.
Install Android Studio
- Download and install Android Studio for Mac
- Run Android Studio
- Getting a "Java not found" message? Download and install Java for OS X.
- You may be prompted for a Java Development Kit (JDK).
- If you need it, use the link provided by the Android Studio Setup Wizard to download and install a JDK.
- Press the Detect button then Next.
- Custom install with each option checked.
- Recommended memory.
- Agree and Finish.
Setup Android Studio for Emulation
Ultimately we want to have one alias we can click on to run just the emulator. To do that we have to...
- Start a new Android Studio project.
- Name it whatever and then Next.
- Choose any API you want.
- I chose Android 4.1.
- "Blank Activity" and then Next.
- Wait until things settle down.
- Tools > Android > AVD Manager.
- Select the Virtual Device you want to run regularly and then right click and choose "View Details".
- Copy the name field which we will need later.
- Click on the little pencil icon to edit the virtual device.
- Show Advanced Settings.
- Scroll down and enable keyboard input.
- Exit Android Studio.
Setup an easy to click Icon
- Create a new file called "Android Emulator.command" on your desktop.
- Fill your file with the following line...
- /Users/daniel/Library/Android/sdk/tools/emulator -avd Nexus_5_API_21_x86
- ...making sure to change daniel to your username.
- ...making sure the text after -avd is the exact name you copied earlier from AVD Manager.
- Save the file.
- Open Terminal and navigate to your desktop.
- Type in...
- chmod +x 'Android Emulator.command'
- This command makes our file executable so we can double click it.
- For bonus points, customize the icon for your new executable file and maybe hide the extension too.
- Double click 'Android Emulator' and enjoy or...
- If the terminal window complains that HAX is not working then reference this guide to increase memory for Intel's HAXM. Alternatively run AVD Manager and lower the memory that your virtual device uses. In my case, I lowered my virtual device to 1 GB on one of my machines and it was happy. My other machine had more memory and did not require this step.
Now you have an easy to click icon that gets you straight into the emulator. Less of a barrier to website testing which is a good thing. No pesky IDE or other anything else to get in your way.
Easy right? Right?! Snaaaaaake!!
The setup and use of Apple's iOS Simulator is delightful in comparison to Android. I honestly wouldn't blame any web developer for balking at the above process. It is a bad experience when all you want to do is make sure your CSS works well on Android devices.
Oh and CTRL + F12 will rotate your Android Emulator. Have fun remembering that because a button or menu option would have been far too easy. *pouty scowl*