The Android Emulator runs most efficiently by emulating an Intel execution environment. To get the best possible performance, you'll need to install a piece of software from Intel named the Hardware Accelerated Execution Manager (HAXM). The most recent version of HAXM is available through the Android SDK Manager. After updating the software through the SDK Manager, you can then find the installer under your sdk directory, in the extras/intel subdirectory.
- [Voiceover] In order to test your Android apps, you'll need a device. If you have a physical device, you'll find that's fastest and easiest, but you can also emulate devices using the Android emulator and virtual devices. When you first install Android Studio, a virtual device is created for you. You can find out what you have available by going to the menu, and choosing Tools, Android, AVD Manager. As of the time of this recording, the default device was based on the Nexus 5 running API 23, or Android 6 Marshmallow, but before you try to run the device, you should make sure that you have a bit of software installed named Intel HAXM.
This software is critical on Intel-based computers to make sure that the Android emulator runs with speed. If you don't have that software installed, you either won't be able to start up the virtual device at all, or if it does start, it'll be really slow. Before we get into creating virtual devices, let's install the HAXM software. Go to your SDK manager, go to the Tools menu choice, then to Android, and SDK Manager. Then go to SDK tools and check that the Intel Emulator Accelerator is selected.
If it is, then you have the installer on your disk already. Now go to your File Manager, Finder on Mac, or Explorer on Windows, then go to your SDK directory. On Mac, I'll press Command + Shift + G, and then go to my Library/Android directory under my home directory. On Windows, you'll need to know where you installed the SDK. My recommendation is always to install it as an Android directory under your home directory, but really it's up to you.
From the Android directory, go to the SDK directory, then to Extras, then to Intel, and from there the path will differ based on whether you're on Mac or Windows. On Mac, look for the DMG file. On Windows, look for the .exe executable. On Mac, open up the DMG, then start up the installer, and on Windows, just start the installer, and if you see a user access control dialog, accept it. On Mac, you might get this dialog.
If so, click Continue. Now, if you already have the software installed on your computer, you'll be notified at this point, but you can go ahead and reinstall it, and this will make sure that you have the most recent version. From this screen I'll click Continue, and whenever you see the prompt to allocate memory, you can either accept the default of two gigabytes, or you can increase it. Here's how you make that decision. On my computer, I have 32 gigabytes of RAM, quite a bit, and so I can afford to allocate more RAM to HAXM.
The amount of RAM you allocate will determine how many virtual devices you can run at the same time. One virtual device will take up usually one to one and a half gigs of RAM. If you want to run two virtual devices simultaneously, you'll want to increase your allocation. If you want to run three, increase it even more, but beware, if your computer only has say eight gigabytes of RAM, you should probably accept the default, and then only run one virtual device at a time.
I'll go back and click Continue again, and I'll see the RAM allocation goes back to the default. I'll click Continue, and Continue again, and Install. Again, the steps differ a bit between Windows and Mac. Just follow the prompts. Once the installation is complete, you can close the dialog, and you're ready to use virtual devices that you open from Android Studio.
- Installing Android Studio on Mac and Windows
- Creating Android Studio projects
- Setting up the development environment, including HAXM and the new Android emulator
- Importing existing code into Android Studio projects
- Exploring the interface, including the editor and project windows
- Managing project builds and dependencies
- Creating new Java classes
- Refactoring code
- Using templates
- Using breakpoints and watch expressions
- Updating apps with Instant Run
- Using Git for version control
Skill Level Beginner
Q: This course was updated on 04/27/2017. What changed?
A: New videos were added that highlight the new features introduced in Android Studio 2.3. In addition, the following topic was updated: update apps with Instant Run.