Development of mobile applications for the platform Android requires constant testing of the code on various device configurations. Since it is physically impossible to have hundreds of smartphones with different screens and OS versions on hand, developers use virtual machines. Emulator allows you to simulate the behavior of a real gadget directly on the computer, which significantly speeds up the debugging process.
Before you can see a working application, you need to properly configure the development environment. Many beginners encounter difficulties when they first start, when the "Play" button is inactive or the emulator simply does not start. In this article, we will look in detail at how to run an Android Studio project in an emulator, eliminating common configuration errors.
Modern versions of IDEs offer powerful tools for managing virtual devices, known as Android Virtual Device (AVD) Manager. Understanding how they work is the key to effective development. We will look at not only the basic steps, but also nuances that are often overlooked in the official documentation.
Checking system requirements and installing components
Successfully launching the emulator directly depends on the presence of the necessary components in the system. First of all, make sure that SDK Manager platforms and tools are installed for the version of the API for which you are writing code. Without System Images, creating a virtual device will be impossible.
Hardware virtualization support is a critical point. On processors Intel must be activated HAXM (Hardware Accelerated Execution Manager) or used WHX on Windows 10/11. For processors AMD and new chips Intel it is recommended to use Android Emulator Hypervisor Driver.
โ ๏ธ Attention: If virtualization technology (VT-x or AMD-V) is disabled in your computer's BIOS, the emulator will either not start or will work extremely slowly. Check your BIOS settings before installing drivers.
You should also pay attention to the amount of RAM. For comfortable operation of the IDE and the emulator at the same time, it is recommended to have at least 8 GB RAMalthough 16 GB is the standard for professional development. Lack of memory often leads to process crashes emulator.exe.
Creating and configuring a virtual device (AVD)
After installing all components, we proceed to creating a device profile. Open Tools โ Device Manager (in older versions of AVD Manager) and click the create a new device button. Here you have to select a physical template, for example Pixel 6 or Nexus 7.
The next step is to select a system image. It is recommended to select versions marked Google Playif your application requires Google services, or standard AOSP images for pure testing. Pay attention to the architecture: for maximum speed on modern PCs, choose images x86_64.
At the hardware configuration stage (Hardware Profile), you can change the amount of allocated memory and screen resolution. By default, the emulator uses dynamic resource allocation, but for heavy applications it is better to manually set limits so as not to โstrangleโ the main operating system.
- ๐ฑ Phone: Standard smartphones with different resolutions and screen diagonals.
- ๐ Wear OS: Specialized images for testing applications on smart watches.
- ๐บ Android TV: Emulators with horizontal orientation for television interfaces.
- ๐ Tablet: Tablet form factors with large screens.
When choosing parameters, it is important to maintain a balance. Too high a resolution (4K) can heavily load the GPU, slowing down the rendering of the application interface. To quickly debug the logic, a standard resolution is enough 1080p.
Launch the emulator and select the target device
When a virtual device is created, it appears in the list of available devices. To run the project, click the green button Run 'app' on the toolbar. If you have multiple devices connected (physical or virtual), the IDE will prompt you to select the target device in the dialog box Select Device.
During the startup process, you will see the emulator window with the logo Android. At this moment, the operating system loads. The first launch of a new image can take up to several minutes as the system performs initial file setup and data caching.
If the emulator is stuck on the logo, try using the function Cold Boot Now in the device action menu. This will force the system to boot again, ignoring the saved state (snapshot), which often solves problems with loading processes freezing.
Basic performance and graphics settings
To ensure smooth animations in your application, you need to properly configure the graphics rendering. In the emulator settings (Settings โ Advanced โ Rendering), you can choose between software and hardware rendering. The mode Hardware - GLES 2.0/3.0 uses the video card of your PC.
Using hardware acceleration significantly increases FPS in the interface and speeds up graphics-heavy applications. However, if your video card drivers NVIDIA or AMD are outdated, the emulator may not work stable. In such cases, switching to software rendering (Software) helps, although this will reduce performance.
It is also worth mentioning the function Snapshot. It allows you to save the state of the emulator when you turn it off, which speeds up subsequent launches. However, when developing applications that are deeply integrated with the system, saved snapshots can cause conflicts, so sometimes they have to be reset.
How to enable multi-core processor in the emulator?
In the AVD configuration, find the "Number of CPU cores" parameter. By default there may be few of them. Increasing to 4 or 6 cores will significantly speed up the compilation of code inside the emulator and the operation of heavy applications, but consumes more host resources.
Do not forget that the emulator is a full-fledged OS running on top of your main system. Closing background applications on the host machine can free up the resources needed for stable operation of the virtual machine.
Working with the file system and network
The emulator has its own virtual file system, isolated from your computer. To transfer files (APK, images, databases), the Drag-and-Drop mechanism or command adb pushis used. The files usually end up in a folder /sdcard/Download inside the virtual device.
The emulator's network communication is also virtualized. By default it uses the host machine's network, but the IP addresses inside the emulator are different. The local host (localhost or 127.0.0.1) inside the emulator points to the emulator itself, and not to your computer.
To access the server running on your PC, you need to use a special address inside the emulator 10.0.2.2. This is a critical point when testing APIs and network requests.
| Network parameter | Address inside the emulator | Description |
|---|---|---|
| Loopback (Host) | 10.0.2.2 |
Access to localhost of the developer's computer |
| DNS server | 10.0.2.3 |
Virtual Emulator DNS server |
| Gateway | 10.0.2.1 |
Virtual router |
| External IP | Dynamic | Address in the virtual network (usually 10.0.2.15+) |
If your application requires access to the Internet, make sure that the antivirus or firewall on your computer is not blocking the process qemu-system. Sometimes you need to add an exception to the Windows firewall rules for the network to work correctly.
Debugging and using ADB with an emulator
For advanced management of the emulator, use the tool ADB (Android Debug Bridge). The emulator is always connected in debug mode, which allows you to instantly receive logs, install applications and take screenshots without unnecessary confirmation on the screen.
ADB commands allow you to simulate various events: incoming calls, SMS, changes in location (GPS) and device orientation. For example, to simulate the arrival of an SMS, you can use the command in the terminal:
adb emu sms send +1234567890 "Confirmation code: 1234"
It is also convenient to take screenshots through ADB for documentation or bug reports. The command adb shell screencap -p /sdcard/screen.png saves the image to internal memory, from where it can be retrieved via adb pull.
โ๏ธ Check before starting debugging
In such cases, it is necessary to indicate the device serial number (for example, emulator-5554) at the beginning of each commands.
Typical errors and methods for eliminating them
One โโof the most common problems is an error ERR_MULTIPLE_DEVICES or inability to find the device. This often happens if there are multiple instances of the emulator running on the system or a physical phone is connected. The solution is to explicitly specify the device in the startup scheme (Edit Configurations).
Another common problem is a black screen at startup. This may be due to incompatibility of video card drivers and rendering mode. Try changing the setting Emulated Performance to Software or updating the GPU drivers.
โ ๏ธ Attention: Android Studio and emulator interfaces are updated regularly. Button layout and menu names may vary between versions. Always check the official documentation if you cannot find the item you need.
If the emulator consumes too many resources and is slow, try reducing the screen resolution or the number of CPU cores in the AVD settings. Closing other heavy applications on the host machine also helps.
FAQ: Frequently asked questions
Why does the emulator run very slowly even on a powerful PC?
Most likely, hardware virtualization (VT-x/AMD-V) is not enabled in the BIOS or the hypervisor driver is not installed. Also check that you are using an x86_64 architecture system image and not an ARM one, since ARM emulation on x86 processors comes with a big performance hit.
Is it possible to run the Google Play Store in the emulator?
Yes, to do this, when creating a virtual device, you need to select a system image marked "Google Play". In regular AOSP images, there is no application store, since it is a proprietary service of Google.
How to reset the emulator data to factory settings?
In Device Manager, click on the three dots next to the device name and select "Wipe Data". This will remove all installed applications and settings inside the virtual machine, returning it to the state immediately after installation.
Why does the microphone or camera not work in the emulator?
You need to check the emulator settings (gear). In the Camera and Microphone section, it should not be โNoneโ, but โEmulatedโ or the connected physical webcam device. Also make sure that the host OS has given permission to access the camera.
Properly setting up the emulator saves hours of debugging. Do not ignore the choice of processor architecture and the amount of RAM, as this is the foundation for stable operation.
Use low-resolution emulators (for example, Pixel 2) to quickly test the logic, and on heavy devices (Pixel 6 Pro) test only the final layout and animations.