Creating an Android Virtual Device (AVD) in Android Studio

Till now we were done with installation of Android studio and create First Android application. In the series of developing the android applications it is mandatory to run compile and run the applications on Emulator/Physical devices. Android has many OS levels. It's very hard to maintain all real devices for debugging. The behavior of each API level and the difference in screens depending on the model can be grasped to some extent with the emulator. To deploy the apps on real devices some times may not possible, so to test the apps we can use emulators. 

In this chapter we are going to learn how to create AVD and deploy the application on emulator. To create an emulator we will use android Device Manager.

What is Device Manager?

Device Manager is an android studio tool which will use to create and manage the emulators.

Launch Device Manager from Tools menu "Emulator" icon , we can also call it from "Tools" "Device Manager".

Android Studio Device Manager

 

On Device Manager window we have one button called "Create device", click on it, will show the below Hardware Profile window.

Android Studio Device Manager 2

 

Select Hardware

This window will show the list of Hardware Profiles for Phones, Tablets, TV, WearOs and Automotives. Choose any Hardware Profile and click on Next button.

Android Studio Device Manager  Hardware Profile

 

API level, ABI, target selection

Now on System Image window choose an API which version of Emulator we want to create and click on Next button.

Android Studio Device Manager System Images

ABI: If it's Intel Core, select x86 or x86_64 and you're good to go. Here i have Mac M1 machine, so it will show arm64-v8a.

  • x86 : emulates an X86 32bit processor
  • x86_64 : emulates a 64bit processor
  • armXXX: emulates ARM processors

If your PC is 64-bit x86, x86_64 will work faster. Later, when using Google API, etc., it will not work unless the Emulator supports it. If you are using a third-party library, there is a cpu dependency, and depending on the library, it seems that emulation can only be done with armeabi-v7a.

Configuration settings

On Verify configuration window we can also change some settings like Camera options, Storage settings etc.

Android Studio Device Manager Advance settings

Click Show Advanced Settings to enable advanced settings. In addition, this depends on the performance of the device to be emulated, so there are some that cannot be selected. 

  • AVD Name:
    • Here you can change the name of the AVD and the settings you have made so far. Enter from here when editing.
  • Startup orientation:
    • The vertical/horizontal setting is set when the emulator is started, but it can be changed even after startup.
  • Camera:
    • Display the camera in simulation, or use the PC camera, etc.
  • Network:
    • Network settings such as UMTS and LTE
  • Emulated Performance:
    • Rendering can be graphics board, soft, switch or automatic.
    • You can also set the number of CPUs.
  • Memory and Storage:
    • Adjustable RAM and heap
  • Device Frame:
    • Select whether to display emulator skins. You can display your own custom skins.
  • Keyboard:
    • PC keyboard and software keyboard settings

Now click on Finish button. It will create an AVD and will display under Device Manager devices list.

Android Studio Device Manager device List

Now launch the AVD/Emulator by click on run icon of the selected emulator under Device Manager devices list.

Note that the created Virtual Device is about 500MB before it is started, but it expands to about 9GB after it is expanded, so if you create a lot, it will put pressure on the hard disk, so be careful, But from Android 10... This Virtual Device can be edited by clicking the pencil icon in Actions

When the emulator starts up, it used to be a single window, but now fits inside the IDE. However, this sometimes caused the emulator not to start or to be locked, so it was solved by making it independent like before (2021.1.1 patch 2)

Android Studio Device Manager device List

If you want to display it in an independent window , uncheck "Launch in a tool window" in "Tools" "Emulator"
from Settings on Windows or Preferences on Mac .

There is a panel on the right. Also, if you click on the other "..." icon, an extended control will appear on the right side.

Android Studio Device Manager

 

power supply
1x1.trans - [Android] Emulator creation, configuration
Click to turn the screen on/off
Press and hold to bring up a dialog to select Power off, Restart, Screenshot.
volume up
1x1.trans - [Android] Emulator creation, configuration
Click to reveal a slider control to increase the volume. Click again to increase the volume further, or adjust the volume with the slider control.
volume down
1x1.trans - [Android] Emulator creation, configuration
Click to reveal a slider control to decrease the volume. Click again to decrease the volume further, or adjust the volume with the slider control.
left rotation
1x1.trans - [Android] Emulator creation, configuration
Rotate your phone 90 degrees counterclockwise
Right rotation
1x1.trans - [Android] Emulator creation, configuration
Rotate your phone 90 degrees clockwise
screenshot taking
1x1.trans - [Android] Emulator creation, configuration
Click to take a screenshot of your device. The default save location is your computer desktop. To change the save location, select   > Settings .
Screenshots from Android Studio's Logcat allow you to add skins and make detailed settings.
Switch to zoom mode
1x1.trans - [Android] Emulator creation, configuration
Click to change cursor to zoom icon
  • Left-clicking on the screen zooms in by 25%, up to about twice the screen resolution of the virtual terminal.
  • Right click to zoom out.
  • Left-click and drag to select the rectangular area you want to zoom in on.
  • Right-click and drag a selection box to return to default zoom.
  • Ctrl-click to touch the screen while in zoom mode

Click the zoom mode icon again to return to normal screen size.

return
1x1.trans - [Android] Emulator creation, configuration
Go back or close a dialog box, options menu, notification panel, or onscreen keyboard.
home
1x1.trans - [Android] Emulator creation, configuration
Return to the home screen. A long press shows items specific to the API level in use.
recently
1x1.trans - [Android] Emulator creation, configuration
(Recently used apps)
Tap to display a list of thumbnail images of recently used apps. Tap the image to open the app. Swipe left or right to remove a thumbnail from the list. This button is not supported on Android Wear.
menu You can see this on the home screen.
keyboard shortcuts
"Ctrl+M" "⌘M"

can be used to simulate a menu button, enabling operations such as opening a menu and selecting an app.

resize You can scale the size using the shortcuts ⌘↑ and ⌘↓.
others
1x1.trans - [Android] Emulator creation, configuration
Click to access additional features and settings shown in the table below.
Install APKs After dragging the APK file onto the emulator screen, an APK installer dialog will appear. After the installation is complete, the added app will appear in the list of apps. If you get an "APK failed to install" dialog, the app is not installed.
add file Drag any file onto the emulator screen and the file will  /sdcard/Download be placed in the directory. Navigate to the location of the file in a manner appropriate to your API level. For example for API 22 go to: Settings > Device :Storage & USB > Internal Storage > Explore (virtual SD card).

Ref: Run your app on the Android Emulator

 

Extended control


If you click the More "..." icon in the emulator panel, extended controls will appear on the right.

Location You can test the GPS, Fusedlocation provider, and simulate the latitude and longitude to the emulator. You can also use geospatial data in GPS Data Exchange Format (GPX) and Keyhole Markup Language (KML) files.
Cellular You can simulate network conditions.
Battery You can set the battery level, status, etc. of the battery and test it.
camera You can set the Virtual Scene displayed by the camera.
phone You can simulate incoming calls and text messages.
Directional pad If your AVD has a d-pad enabled in the hardware profile, you can use the d-pad in the emulator
microphone You can emulate what it would be like if your headset had a microphone.
fingerprint It can simulate 10 different fingerprint scans.
Virtual Sensors It can emulate some sensors such as accelerometers.
Bug reports You can check the bug report data.
Snapshots You can take a still image of the emulator screen in .png.
screen record You can shoot a video of the emulator screen in .webm.
Google Play You can sign in to Google Play.
Settings Setting the storage location of Snapshots, etc.
Help You can find shortcuts for each function.