The Android emulator uses system images to support testing with virtual devices. System images based on the ARM CPU architecture can be very slow, so usually it's better to use the Intel-based system images. These depend on an external software package, Intel's hardware accelerator, that you download with the rest of the SDK. Before using a virtual device for the first time, you should install and configure the Intel software.
- Before you create virtual devices for testing your application, you should install a bit of software from Intel called the Hardware Excelleration Manager. The installer for this software is included when you install the SDK. You should make sure you have the most recent version of the installer. If you have a project open, you can get to the SDK manager by selecting Tools. Android. SDK Manager. If you've just created a new project and you don't see these menu choices yet, close the menu and wait a few moments until all of the activity at the bottom of the screen has finished.
Then try again. These menu choices are added dynamically when a project is being built. From this menu choose Tools. Android. SDK Manager. And that will take you to the Settings Dialog on Windows or the Preferences Dialog on Mac. And either way you'll be in the Android SDK category on the left. Go to the SDK Tools tab and then locate the Intel X86 emulator accelerator and make sure you have updated the software to the most recent version.
If you see a check box and installed, that means you have the most recent version. If you see that there's an update available, check the check box and then click apply and then continue after the installer has been upgraded. Once you verify that you have the most recent version, then you need to locate the installer on your hard disk. It'll be under your SDK directory. I've installed my SDK under Android, SDK, under my home directory. On Mac, the default location is under the library directory under your home directory.
And then once again, Android. And SDK. From the SDK directory, go to extras, and then to Intel. And then to hardware accelerated execution manager. You'll find an installer for your operating system. On Windows, the installer is simply named intelhaxm-android but on Mac, it'll be named slightly differently. Start the installer and if you see a security prompt of any sort, simply click yes. Now, the installer will look different from Windows to Mac but the functionality is the same.
If you've installed this software previously, you might see a message indicating that you're uninstalling and reinstalling it when you run this application again. The important thing here is to understand how memory is allocated and used with the HAXM software. The default is 2 gigabytes, and that works fine if you have a computer with 8 gigabytes of RAM. But if you have more RAM on your computer you might want to allocate more here. And here's why. Each virtual device that you startup in your computer will reserve a certain amount of memory.
The default for new virtual devices when you create them through android studio, is 1.5 gigabytes. So, if you only allocate 2 gigabytes in HAXM, and a virtual device wants to use one and a half gigabytes, then you can only run one virtual device at a time. If your computer has more RAM available, I recommend increasing the amount of RAM that you assign here. As you can see, through this message, my computer has plenty of memory. I have 32 gigabytes installed on this computer.
So I'm going to set the amount of RAM that I'm assigning to HAXM to 4 gigabytes. And that will allow me to open more than one virtual device at the same time. Once you've assigned the amount of RAM, click next and complete the installation. And if the installation is complete, you'll be ready to create new virtual devices. If you see an option to launch the HAXM documentation, you can uncheck that and click finish, and then return to android studio, and you'll be ready for the next step.
Creating and launching virtual devices to test your applications.
- Installing Android Studio
- Creating your first Android Studio project
- Managing profile files, including Gradle scripts and support libraries
- Defining screens with activities
- Implementing designs in XML layouts