Creating and Android Emulator
The Android emulator or Android virtual device is an essential tool for any Android app developer. There is no substitute for testing on real devices and I cannot stress how important this is. However, not all of us have the plethora of device types and Android versions to test with and so the emulator is must for any project. What we will look at in this tutorial is how to build an emulator and more importantly, how to maximise its speed to overcome the traditional lethargy associated with the emulator.
Assuming you have successfully installed Android Studio, you will be able to access the emulator function via the AVD manager. Simply click on the AVD manager icon.
You will be presented with the manager screen. This contains any existing emulator instances that can be loaded, edited or viewed. To create a new device, simply click on the 'create new device' button. You will then be guided through a wizard to create a new emulator instance.
There are many predefined phones, tablets, Android wear and Android TV devices. You also have the option to create a customized device if needed. The predefined device types will meet most, if not all, requirements for screen sizes and screen densities.
On selecting a device type, click 'next' and you will be taken to what is probably the most critical screen. This screen will have details as to what Android SDK's are currently loaded. You are able to download any versions that you have not installed should you need them.
In order to make the emulator run as fast as possible you will need to select and x86 system image. ARM related images cannot take advantage of any virtualization technology and so will be relatively sluggish.
Windows users running on an Intel processor that supports Virtualization Technology will be able to take advantage of all speed gains. The processor's virtualization technology needs to be enabled in the bios of the machine. It is generally disabled by default. You must select an Android API of 17 or above for the emulator. The final component that needs to be installed is Intel's Hardware Accelerated Execution Manager (HAXM). This is generally downloaded with the SDK. You can verify it is loaded by accessing the SDK manager.
If you are using an AMD processor you can use their virtualization technology, AMD-
Clicking 'next' will take you the next stage of the build process. On this screen you can see two key options. These are 'snapshot' and 'GPU emulation'. If you are running API 15 rev 3 or above you can take advantage of the Graphics Processing Unit to make the emulator screen render faster. The 'snapshot' option allows the emulator to load faster. However, you cannot use both options simultaneously and so use 'snapshot' if you are using ARM based system images. ARM based images where essential if you wanted to run an emulator on Android versions prior to 4.0.3.
Click OK and you are done. When the device is built, start the emulator by clicking the play button.