Development of mobile applications for the platform Android requires thorough testing on various hardware configurations. Buying dozens of physical smartphones to test your code's compatibility is an expensive and impractical solution. This is where the built-in tool comes to the rescue Android Virtual Device (AVD), allowing you to emulate the operation of real gadgets directly on your computer.
Creating a virtual device opens up endless possibilities for the developer: from checking the layout on screens of different sizes to testing the application on different versions of the operating system. You can simulate screen rotation, changes in battery level, geolocation, and even simulate incoming calls without the need to have a physical device at hand.
In this article, we will take a detailed look at the process of setting up the emulator, from installing the necessary components to fine-tuning performance. Understanding how to properly create and configure AVD Managerwill be the foundation for effectively debugging your projects in the environment. Android Studio.
Preparing the development environment and installing components
Before you start creating your first emulator, you need to make sure that your development environment is completely ready for work. A standard installation Android Studio usually includes basic tools, but for virtual machines to work correctly, additional installation of specific packages is often required via SDK Manager.
Open the project settings and go to the package management section. You will need to find and check the boxes for the components responsible for emulation. It is critically important to have Android Emulatoras well as System Images for those versions of Android on which you plan to test the application.
โ ๏ธ Attention: Make sure that you have enough free space on your hard drive. System images and emulator data can take up from 5 to 15 GB of disk space, depending on the number of Android versions installed.
It is also worth checking for the presence of Hardware Acceleration (hardware acceleration). For Intel processors this is technology HAXM (although in new versions it is replaced by Hypervisor), and for AMD it is support for virtualization in the BIOS. Without enabling these functions, the emulator will work extremely slowly or will not start at all.
After installing all components, restart the IDE. This ensures that all new tool paths are correctly indexed and available for use in the tools menu.
If you have an AMD processor and are using Windows, make sure that SVM (Secure Virtual Machine) technology is enabled in the BIOS, otherwise the emulator will not be able to use hardware acceleration.
Launch Device Manager and select configuration
For To start working with virtual machines, you need to open a specialized management interface. In the top menu Android Studio select item Tools, and then Device Manager (in older versions it was called AVD Manager). A window will open with a list of already created devices or a proposal to create a new one.
Click the button Create Device (or โCreate deviceโ) to launch the setup wizard. You will see a list of preinstalled hardware configurations (Hardware Profiles). Here you can select a specific model, for example Pixel 6, Galaxy S22 or tablet Pixel Tablet.
- ๐ฑ Phone: Standard smartphones with different screen diagonals and aspect ratios.
- ๐ป Tablet: Devices with a large screen, useful for testing adaptive interface.
- โ Wear OS: Emulators for smartwatches with a round or rectangular display.
- ๐บ TV: Configurations for Android TV with support for remote controls.
- ๐ Automotive: Specialized images for testing multimedia systems of cars.
The choice of profile determines the physical parameters of the device: screen resolution, pixel density (DPI), amount of RAM and the presence of physical buttons If none of the preset configurations suits you, you can create your own profile by clicking the button New Hardware Profile and setting the parameters manually.
Selecting a system image and Android version
After selecting the hardware, the wizard will prompt you to select a system image. This is the most important step, since it determines the version of the operating system Androidthat will be installed on the virtual device. The list displays available API levels and Android version names, such as Tiramisu, Upside Down Cake or Vanilla Ice Cream.
Pay attention to the โRelease Nameโ and โAPI Levelโ column. For maximum compatibility, it is recommended to create emulators for both the latest versions and the minimum version (minSdkVersion) that your application supports. If the required image is not loaded, next to it there will be a button Download.
| Android version | API Level | Support status | Recommendation |
|---|---|---|---|
| Android 14 | 34 | Current | Required for new applications |
| Android 13 | 33 | Stable | Main target audience |
| Android 12 | 32 | Stable | Wide distribution |
| Android 11 | 30 | Supported | Minimum recommended version |
When choosing a system image, pay attention to the ABI type (Architecture). For modern computers with x86_64 processors, select images marked Google APIs or Google Play and architecture x86_64. Images with architecture armeabi-v7a will work much slower due to the emulation of processor instructions.
โ ๏ธ Attention: The interfaces and capabilities of system applications may differ in the โGoogle Playโ and โGoogle APIsโ images. Images from Google Play include a full set of store services, which is important for testing in-app purchases.
Configuring virtual device settings
At the final stage of the setup wizard, you will be taken to a confirmation screen (Verify Configuration). Here you can change the device name (AVD Name), which is useful for identification if you are creating multiple emulators. By default, the name is generated automatically based on the model and OS version.
Click on the link Show Advanced Settingsto access advanced options. In this section you can change the amount of internal memory (Internal Storage) and memory card (SD Card). Standard values โโare usually sufficient, but for testing applications that work with large files, the volume should be increased.
What is_snapshot_in the emulator settings?
The (Snapshot) function allows you to save the state of the emulator at the time of shutdown. The next time you start the device, the device will be restored instantly, and will not go through a long system boot procedure. This saves the developer time, but takes up additional disk space.
Pay special attention to the section Emulated Performance. Here is the setting Graphics. The default is Automatic, which is usually the best choice. However, if you encounter artifacts on the screen or crashes, you can try switching the mode to Software (software rendering) or Hardware (forced use of GPU).
Also in the advanced settings you can change the screen orientation at startup, configure the camera (use a PC webcam or emulate static image) and even change the scale of the emulator interface on the developer's monitor.
Optimal graphics settings (Hardware) require installed video card drivers. If the emulator is slow, check that the NVIDIA or AMD drivers are up to date.
Launch the emulator and first steps
After pressing the button Finish your virtual device will appear in the list Device Manager. To start, click on the โPlayโ icon (green triangle) in the line with the device. A separate emulator window will open and the process of loading the operating system will begin.
The first launch may take from 30 seconds to several minutes, depending on the power of your computer and the type of drive (SSD significantly speeds up the process). You will see the Android logo, after which the lock screen or desktop will appear, depending on the image settings.
The emulator is controlled both with the mouse and using key combinations. For example, the button F12 or the combination Ctrl + M (Cmd + M on Mac) emulates pressing the โMenuโ button. The F11 or Ctrl + P button switches the screen orientation between portrait and landscape.
- ๐ "Back" button: emulated by clicking on the arrow in the control panel or the key
Esc. - ๐ Button โHomeโ: returns to the main screen, similar to the key
F2. - ๐ Search button: calls up voice search or assistant.
- ๐ Volume control: volume up and down buttons in the sidebar.
The right side panel of the emulator contains advanced control tools. There you can change the location (Extended Controls -> Location), rotate the device, take a screenshot or record a video of the screen to demonstrate the functionality of the application.
Optimizing performance and solving problems
Android emulation is a resource-intensive task. If you notice that your computer starts to slow down when working with the emulator, you should check your RAM allocation. In the device settings (_EDIT_ in the manager) you can manually specify the amount of RAM. Do not allocate too much memory so as not to leave the host system without resources.
A common problem is the slow operation of the GUI. Make sure that in the emulator settings in the section Graphics mode is selected Hardware - GLES 2.0/3.0. This shifts the load of rendering the interface to your computer's video card, significantly relieving the CPU.
โ ๏ธ Warning: Antivirus software can sometimes conflict with emulator processes, deeming them suspicious. If the emulator does not start or crashes immediately after startup, try adding the folder with the Android SDK to the antivirus exceptions.
There is also a problem with โcoldโ and โhotโ starts. If you don't use the Snapshots feature, every run of the emulator will be full. Using snapshots allows you to pause the device and resume it almost instantly, which is critical for productivity with frequent application restarts.
โ๏ธ Emulator optimization checklist
Frequently asked questions (FAQ)
Why does the emulator work very slowly even on a powerful PC?
Most likely, hardware virtualization is not enabled in the BIOS/UEFI of your computer (Intel VT-x or AMD-V technologies). Also check that you are using an x86_64 architecture system image, not ARM, and that Hardware mode is selected in the graphics settings.
How to transfer a file from a computer to the emulator?
The easiest way is to drag-and-drop the file from a folder on the computer directly into the window of the running emulator. The file will be automatically saved to a folder Downloads inside the virtual device. You can also use the command adb push via the terminal.
Is it possible to run several emulators at the same time?
Yes, Android Studio allows you to run several virtual devices in parallel. This is convenient for testing interaction between applications or checking work on different versions of Android at the same time, but this will require significant RAM resources.
How to reset the emulator data to factory settings?
B Device Manager click on the three dots to the right of the device name and select Wipe Data. This will delete all user data, installed applications and settings, returning the emulator to the state immediately after the system was first installed.
Where are the emulator image files stored on disk?
By default, emulator data is stored in a hidden user folder. On Windows, the path usually looks like C:\Users\User_Name\.android\avd, on macOS and Linux - ~/.android/avd. There are files with the extension .avd and configuration files .ini.