Skip to main content

How to Create an Android Virtual Device using Android Emulator

This is an important chapter of Mobile Testing as this will teach us How to Create An Android Virtual Device using Android Emulator or AVD Manager which is used during the Manual Mobile Testing and in Mobile Automation using Appium. But before Moving ahead with this long chapter it is necessary to understand the terms like Emulator, Android Virtual Device (AVD) & AVD Manager.

What is an Emulator?

An Emulator is an application that emulates real mobile device softwarehardware and operating systems, allowing us to test and debug our application. It is generally provided by device manufacturer. Mobile emulators are free and provided as a part of SDK with each new OS release. As a developer or a tester, you can configure the emulator closely resemble the devices on which you plan to deploy your application.
A typical Android Emulator looks like this:
Emulator
The emulator window consists of a device screen on the left and phone controls/keyboard on the right. The device screen initially displays ‘ANDROID‘, and then displays the graphical logo, while the Android platform associated with the AVD is initializing.

Tips to use Emulators effectively

  • Use keyboard commands to easily interact with emulators.
  • Mouse also works with Emulators, so one can use Mouse click, dragging & scrolling and keyboard arrows buttons.
  • Buttons displayed on the right side of the Emulator also work with the help of the mouse click, like volume up/down, Home, Menu etc.
  • If the machine is connected to internet, same can be used with in the Emulator as well.
  • Notifications such as incoming messages appears in the white notification bar at the top of the screen, along with battery life and so on.
Note: Android Emulator is a powerful tool but no substitute for testing on the true target devices.


What is AVD Manager?

AVD Manager is a tool to create and manage Android Virtual Devices(AVDs), which define device configuration for theAndroid Emulator. Before you can actually run an emulator, you need to install the Android SDK on your machine, and define an AVD which defines the hardware characteristics of the emulator. You can define things like the device RAM, whether there is touch screen and/or keyboardcamera supportaudio playback support, etc. You can create several AVDsto test your device on several virtual devices.


How to Create an Android Virtual Device using AVD Manager


Prerequisites for AVD Manager


Once installation of the above prerequisites are done, we need to launch the SDK Manager to download relevant files to create an emulator and run the virtual device. In command line(cmd), type in android sdk. It would open the SDK Managerfor you to download the relevant files. In the SDK Manager select the files as shown below. This will help you create a virtual devices.
AVD_Manager_7
Select the above files and choose to install, once done close the SDK manager.
  • Get the latest SDK tools: Under Tools, install Android SDK Tools, Android SDK Platform tools and Android SDK Build Tools.
  • Get the Android API: Select different Android versions and APIs for AVDs. These are the different environments for your application under test. You can choose multiple from Android 4.4.2 to 5.1.1.
  • Get the Extras: Install the default selections as well as the “Intel x86 Emulator Accelerator (HAXM installer)”.

There are two ways to create Android Virtual Devices for Mobile testing:
  • Using Command Line
  • Using AVD Manager

Creating a New Android Virtual Device using AVD Manager

First step is to launch the AVD Manager and for that there are number of options you can follow:
  • Launch AVD Manager using Program Menu
    Go to Start > All Program > Android SDK Tools > AVD Manager
  • Launch AVD Manager using Command Line
    Go to Run and type cmd to open command prompt window. Type Android AVD.
  • Launch AVD Manager from folder location
    Browse to Android SDK folder and Double-click on AVD Manager.

Either of the above ways, it would open the Android Virtual Device Manager, which would help you create the virtual devices. The AVD Manager main screen shows one default virtual device, which is Nexus 5.
1) Click on Create button to create a new AVD.
AVD_Manager_1

2) A pop up will open, follow the below screenshot for the values. Choose a name for the AVD, in case simulating a specific device, you might want to name it as such. For example NexusSix-4.4 that refer to an AVD that simulate Nexus-SIx which runs on Android 4.4.2 version or anything that resemble your device configuration. In this test I choose a very generic nameAndroid to keep it simple.
AVD_Manager_2
Note: You can play around with different configurations for your virtual device.

3) Click on OK to proceed with the save changes.
AVD_Manager_3

4) After you complete above steps, the emulator will be displayed under the Android Virtual Devices tab, configured on the AVD Manager. Now Select the AVD name and click on Start on the right.
AVD_Manager_4

5) This would launch the pop up with few options, you may choose as you want. Once done click on Launch, this will launch the emulator.
AVD_Manager_5
  • Scale display to real size: This causes the resolution of the emulator’s display to be scaled to match the screen size.
  • Wipe user data: This would wipe any previous app installation you have done and would launch a plain fresh emulator. Wipe user data.
  • Launch from snapshot: This cause the emulated device to be started from a previously saved snapshot of the device’s state. The emulator launches much faster when launched from a snapshot.
  • Save to snapshot: This causes the emulated device’s state to be saved to a snapshot upon device exit.

6) Emulator will launch, it would take few minutes to display the Home Screen of the virtual android device, actually it is as equal to Switch On the real Mobile device.
AVD_Manager_6
Note: You can use the command ‘adb devices‘ to see if the adb is detecting the emulator. This basically completes the android SDK installation part.
Note:If ANDROID logo appears for more than 15-30 minutes, something has probably gone wrong. Reboot your computer, start AVD Manager, delete our created ‘Android’ AVD, recreate this AVD, and relaunch new AVD.
The above screenshot shows the emulator window with 5554:Andoid in its title bar. Value 5554 identifies a console port that you can use to query and control the AVD’s environment. Android supports a maximum of 16 concurrently executing AVDs, where each AVD is assigned an even-numbered port number that starts at 5554. It means that we can initialize more then one AVD at the same time and can test the app with parallel execution.

Comments

Popular posts from this blog

JMeter Exceeded Maximum Number of Redirects Error Solution

While running performance test, JMeter allows maximum 5 redirects by default. However, if your system demands more than 5 redirects, it may result in JMeter exceeded maximum number of redirects error. In this post, we have listed down steps to overcome this error. Actual error in JMeter: Response code: “Non HTTP response code: java.io.IOException” Response message: “Non HTTP response message: Exceeded maximum number of redirects: 5” This error is noticed because  JMeter  allows maximum 5 redirects by default and your system may be using more than 5 redirects. You need to increase this count to more than 5 in jmeter.properties file. Follow below steps to achieve this. Navigate to /bin directory of your JMeter installation. Locate jmeter.properties file and open it in any editor. Search for “httpsampler.max_redirects” property in opened file. Uncomment the above property by removing # before it. Change to value to more than 5 Eg. 20. Save the file and restart JMeter. If

SSO with SAML login scenario in JMeter

SAML(Security Assertion Markup Language) is increasingly being used to perform single sign-on(SSO) operations. As WikiPedia puts it, SAML is an XML-based open standard data format for exchanging authentication and authorization data between parties, in particular, between an identity provider and a service provider. With the rise in use of SAML in web applications, we may need to handle this in JMeter. This step-by-step tutorial shows SAML JMeter scenario to perform login operation. First request from JMeter is a GET request to fetch Login page. We need to fetch two values ‘SAMLRequest’ and ‘RelayState’ from the Login page response data. We can do this by using  Regular Expression Extractor . These two values need to be sent in POST request to service provider. Refer below image to see how to do this. We will get an HTML login page as a response to the request sent in 1st step. We need to fetch values of some hidden elements to pass it in the next request. We can do this b

A Tutorial to Send Email using JMeter

Sending email is a mundane activity in any professional’s life. It’s a common medium for communication nowadays. Therefore performance testing of email server is not only important but necessary for an organization. JMeter can be helpful to perform load testing in such scenarios. In this tutorial, we will see how JMeter can be used to send email. We will use SMTP Sampler of JMeter to send an email. JavaMail API is needed to enable email functionality in JMeter. Download it from  here  and paste the jar in JMeter’s lib folder. Now, perform below steps to configure SMTP Sampler. Add a new Thread Group under Test Plan. Right click on Thread Group and select Add–>Sampler–>SMTP Sampler. We need to populate SMTP server’s details in this sampler. We will use GMail for sending an email. For this, enter these values in SMTP Sampler fields. Server: smtp.googlemail.com, Port: 587. Provide values in Email Address From and To fields of Mail Settings section to specify sender and reci