Developing applications for mobile devices is impossible without testing, and physical smartphones are not always available at hand in the required number of models. Android Studio provides developers with a powerful tool - an emulator, which allows you to run a virtual device directly on your computer. This eliminates the need to constantly connect devices via USB and makes it possible to simulate different screen configurations, operating system versions and hardware characteristics.
However, beginners often encounter difficulties during the first setup: the emulator may not start, slow down, or produce errors at startup. Virtual Device (AVD) requires correct BIOS configuration and installation of additional SDK components. In this article, we will analyze all the stages of creating a virtual device, eliminate common errors and learn how to optimize its operation for comfortable debugging of code.
To get started, you will need an installed development environment and a sufficient amount of free disk space. Emulation is a resource-intensive process that uses the processor and RAM of your PC. Let's look at how to prepare the system to launch a virtual environment.
Checking system requirements and enabling virtualization
Before you try to create a virtual device, you need to make sure that your hardware and software are ready to go. The key is to support and enable virtualization technology in the processor. Without this step, the emulator will either not start or will work extremely slowly, using software emulation instead of hardware.
For Intel processors this technology is called VT-x, and for AMD - AMD-V. Checking the status is done through the Task Manager in Windows or the Terminal in Linux/macOS. If the function is disabled, you will have to restart the computer, enter the BIOS/UEFI and find the corresponding item in the processor settings (often located in the Advanced or Security sections).
โ ๏ธ Attention: On some corporate computers, access to BIOS settings may be blocked by the administrator. In this case, starting the emulator will not be possible without obtaining access rights.
It is also critically important to have the component installed Android Emulator in the SDK Manager. Without this package, the create device button will be grayed out or will result in an error. Make sure you have at least 4 GB of free RAM, as the emulation process itself can consume a significant amount of resources.
Creating a new virtual device (AVD)
The creation process begins by opening the device manager. In the top menu of Android Studio, select Tools โ Device Manager (in older versions AVD Manager). In the window that opens, you will see a list of already created devices or a blank screen if you are starting the environment for the first time.
Click the button Create Device (or "Create Virtual Device"). A setup wizard will open and prompt you to select a physical profile. Here you can choose a tablet, phone, Android TV or even Wear OS. For most tasks, the standard Pixel or Nexus.
โ๏ธ Check before creating AVD
At the next stage, select the system image (System Image). This is the actual version of Android that the device will emulate. It is recommended to choose images marked Recommendedas they are the most stable. Pay attention to the "API Level" column - it indicates the Android version, and "Type" determines the presence of Google Play Services.
After selecting the image, the system will prompt you to confirm the download of the necessary files if they have not yet been downloaded. This process may take time depending on the speed of your Internet connection. Once the download is complete, click Finishand the device will appear in the list of available ones.
Configuring performance and graphics settings
After selecting a profile and system image, but before the final launch, it is important to configure the settings for a specific instance. Click on the pencil icon (Edit) next to the created device and select Show Advanced Settings. This is where the keys to performance are hidden.
The Emulated Performance section contains the Graphics parameter. The default value is Automatic, which usually means using hardware acceleration of your video card. If you experience screen artifacts or crashes, try switching the mode to Software - GLES 2.0, although this will significantly reduce FPS.
| Option | Recommended value | Impact |
|---|---|---|
| Graphics | Automatic / Hardware | Use GPU for rendering |
| Multi-core CPU | 2 or 4 cores | Application speed |
| RAM | 2048 MB | OS stability |
| VM Heap | 576 MB | Memory for Java applications |
You can also configure the amount of RAM here (RAM) and the number of processor cores that will be allocated to the emulator. You should not allocate all available resources, otherwise the main operating system will begin to slow down. It is optimal to allocate about half of the available cores and 2-4 GB of memory.
To speed up the emulator on Intel processors, make sure that the "Intel x86 Emulator Accelerator (HAXM)" component is installed in the SDK Tools if you are using Windows or macOS.
Running the emulator and debugging the application
When the device created and configured, it is launched by clicking the Play button (triangle) in the device manager or through the Run button (green triangle) in the main IDE window if the device is selected in the list of target devices. The first startup always takes longer as the system goes through a cold boot procedure.
After booting, you will see the standard Android lock screen. Now you can install applications. If you run the project from Android Studio, the application will install automatically. If you need to install the APK manually, simply drag the file .apk to the emulator window.
Standard debugging tools are used to interact with the device. You can take screenshots, change screen orientation and simulate geolocation through the emulator control panel. This panel is called up by a button with three dots at the bottom of the virtual device window.
โ ๏ธ Attention: The emulator interface and the set of available functions may differ depending on the version of Android Studio and the type of system image selected (with or without Google Play).
Using the command line for control
For advanced users or process automation, it is convenient to launch the emulator through the terminal. This allows you to pass specific flags that are not always available in the GUI. The launch command is located in the folder emulator inside the SDK directory.
emulator -avd NameOfYourDevice -netdelay none -netspeed full
In this command -avd indicates the device name, and the flags -netdelay and -netspeed emulate network conditions (no delays and maximum speed, respectively). This is useful for testing application behavior on poor internet.
There are many other useful flags. For example, -no-snapshot causes the emulator to ignore the saved state and load cleanly every time. This helps to avoid bugs associated with caching the system state.
List of useful command flags
-no-snapshot-load: Do not load the saved state (cold start). -no-audio: Disable audio (useful for saving resources). -gpu off: Completely disable GPU emulation (to debug graphical errors).
Typical errors and solutions
One โโof the most common problems is an error HAXM is not installed or messages that x86 emulation is impossible. This almost always means that virtualization is disabled in the BIOS or the HAXM driver is not installed through the SDK Manager. Check the "SDK Tools" tab in Android Studio settings.
Another common problem is a black screen at startup. This may be due to incompatibility between the graphics card driver and the emulator version. Try updating your video card drivers or, as mentioned earlier, switching the graphics rendering mode to Software in the AVD settings.
If the emulator starts but is unbearably slow, check your antivirus. Some antivirus apps block the emulator's access to processor instructions, considering its behavior suspicious. Add the folder with the Android SDK to the exceptions.
90% of problems with running the emulator can be solved by checking that virtualization is enabled in the BIOS and updating the Android Emulator component in the SDK Manager.
Optimizing work and reducing resource consumption
The emulator is a heavy tool, and its operation can slow down everything computer. To reduce the load, close unnecessary tabs in the IDE and other resource-intensive applications while debugging. Reducing the emulator screen resolution in its settings also helps.
Use the function Quick Boot (fast loading). It saves the state of the emulator when closing, allowing you to launch it in a couple of seconds, as if you were just waking up your smartphone. This feature is enabled by default in modern versions of Android Studio.
If you don't need a full GUI, just a console for tests, consider running the emulator in -no-windowmode. This will launch a virtual device in the background, and you can connect to it via adb, saving resources on rendering the interface.
How to increase the internal memory of the emulator?
By default, the emulator creates a data file of a limited size. To increase it, when creating an AVD, in the โShow Advanced Settingsโ section, find the โInternal Storageโ item and specify the desired volume, for example, 4096 MB. For an already created device, it is easier to create a new one with the necessary parameters.
Why does the emulator not see the Google Play Store?
Not all system images contain Google services. When creating a device, select images that have a checkmark or a triangle icon in the "Play Store" column. Images marked as "Google APIs" contain only libraries for developers, but not an application store.
Is it possible to run the emulator on an ARM processor?
Yes, but the performance will be significantly lower than on x86/x64 processors if binary code translation is not used. For Apple Silicon processors (M1/M2/M3), there are native ARM64 images that work very quickly and efficiently.
Where is the emulator data stored on disk?
Virtual device data is usually stored in a hidden user folder. On Windows, the path looks like C:\Users\UserName\.android\avd. There are configuration files and large disk image files that take up the main space.