Why emulator is very slow in Android Studio?

144,427

Solution 1

The Best Solution is to use Android Emulator with Intel Virtualization Technology.

Now if your system have a Processor that have a feature called as Intel Virtualization Technology, then Intel X86 images will be huge benefit for you. because it supports Intel® Hardware Accelerated Execution Manager (Intel® HAXM).

To check that your processor support HAXM or not : Click Here

You need to manually install the Intel HAXM in your system. Follow these steps for that.

  • First of all go to - adt -> extras -> intel -> Hardware_Accelerated_Execution_Manager
  • Make sure that Intel Virtualization is enabled from BIOS Settings.
  • Now install Intel HAXM in your system and select amount of memory(i prefer to set it as default value).
  • After installation create new Android Virtual Device (AVD) which should have a Target of API Level xx
  • Now set the CPU/ABI as Intel Atom(x86).
  • If you are on Windows then do not set RAM value more than 768 MB while setting up an emulator.
  • Run the emulator. It will be blazing fast then ordinary one.

Hope it will be helpful for you. :) Thanks.

Solution 2

Just edit the AVD settings as below,

Enable snapshot options and please use INTEL HAXM software for speedup.just visit https://software.intel.com/en-us/articles/intel-hardware-accelerated-execution-manager-intel-haxm and download...

Solution 3

I tried all the suggested remedies and none had any impact. The Android Studio emulator experience was simply unusable with my setup (Windows 10, AndroidStudio 3.5, Quadcore 3.2 Ghz, 32GB with SSD drive).

I tried Updating Studio, Installing Intel HAXM, Changing the memory settings via SDK, using an actual device, excluding the various folders from in the Windows Anti-virus among other things.

The solution that made it work like a breeze was to exclude the Android Debug Bridge (adb.exe) "as a process" from the Windows Security / Virus Protection. You can either do it yourself or read the details below to know how to do it.

I suggest verifying the severity of the speed issue yourself. The same will be used to verify the difference immediately after you apply the remedy. Running the options from within Android Studio just makes it more complex.


Steps to check the issue:

  1. Get the path for your Android SDK Tools. You can find it from SDK Manager -> Appearance and Behavior -> System Settings -> Android SDK.

  2. Open a command prompt or terminal window. You can do right click on Windows (Start) Icon -> Run and execute "cmd". This should give you a windows command prompt or terminal window.

  3. In the terminal window, change your drive and path to your Android SDK folder using the CD command. Now change to the sub-folder Platform-tools.

  4. You will find the Android Debug Bridge (adb.exe) in this folder. This plays a very crucial role in operating the emulator as well as the actual device.

  5. In the terminal window, execute the adb.exe tool with the command adb. It should instantly return back with the help parameters for adb.

  6. Now execute adb.exe with a command like - adb devices. This should simply stall and take several seconds to come back with the information even if you have no devices or emulator running. In my setup it took almost 30 seconds. This is the issue.

Anything you do with the emulator goes via adb and gets stuck here. Once the remedy is applied, it should execute the adb devices command as instantly as the simple adb command without any parameter.


Steps to remedy:

  1. Go to Windows "Virus and Threat Protection" setting. There are several ways to reach it. You can use Right Click on Windows (Start) Icon and choose Settings. Choose Update & Security, then Windows Security, then Virus and Threat Protection.

  2. You will find the option Virus and Threat Protection Settings. Select it. You will find several options, look for Exclusions. Select the option Add or remove exclusions. This will take you to the list of Files, Folders, Processes which are presently excluded by the windows anti-virus. It may be empty or may have some data.

  3. Select "+ Add an Exclusion". You will find 4 options - File, Folder, File Type and Process. This is critical. Please choose Process.

  4. In the "Enter Process Name" input box type in the name adb.exe. Please dont forget to type in the extension, just putting adb will not work. Accept the input with "Add" button.

You are done. Now goto the command prompt again and follow the same steps you did earlier to check the issue. Hopefully you will be pleasantly surprised and your entire Android Studio emulator experience should become seamless.

Note that the steps may slightly vary depending upon your version of Windows, Android Studio and SDK tools however it should still apply.

Solution 4

The new Android Studio incorporates very significant performance improvements for the AVDs (emulated devices).

But when you initially install the Android Studio (or, when you update to a new version, such as Android Studio 2.0, which was recently released), the most important performance feature (at least if running on a Windows PC) is turned off by default. This is the HAXM emulator accelerator.

Open the Android SDK from the studio by selecting its icon from the top of the display (near the right side of the icons there), then select the SDKTools tab, and then check the box for the Intel x86 Emulator Accelerator (HAXM installer), click OK. Follow instructions to install the accelerator.

Be sure to completely exit Android Studio after installing, and then go to your SDK folder (C:\users\username\AppData\Local\extras\intel\Hardware_Accelerated_Execution_Manager, if you accepted the defaults). In this directory Go to extras\intel\Hardware_Accelerated_Execution_Manager and run the file named "intelhaxm-android.exe".

Then, re-enter the Studio, before running the AVD again.

Also, I found that when I updated from Android Studio 1.5 to version 2.0, I had to create entirely new AVDs, because all of my old ones ran so slowly as to be unusable (e.g., they were still booting up after five minutes - I never got one to completely boot). As soon as I created new ones, they ran quite well.

Solution 5

As @Xavi mentioned, Android Emulator is normally slow and lags a lot. Either test your app on an actual device or use an alternative emulator such as BlueStack or Android-X86.

Another tip for using emulator is to not close if you ain't done testing your application. Just leave it open. In this case you skip the time it takes to launch.

Share:
144,427
Admin
Author by

Admin

Updated on July 22, 2022

Comments

  • Admin
    Admin almost 2 years

    I just setup Android Studio on my PC, which is new launch to develop Android application.

    My problem is that, when I try to run my small app in emulator, it take to much time to launch and after then emulator is working slow too.

    AVD settings

    AVD Name: Glaxy
    Device: Glaxy Nexus (4.65", 720x 1280: xhdpi)
    Target: Android 4.2.2 - API Level 17
    Memory Option: Ram 500, VM Heap 64
    Internal Storage: 200MiB

    I have good window pc: Intel Core 2 Duo 2.93Ghz and Ram is 3gb

    I am new in Android development and java.

  • Admin
    Admin almost 11 years
    Thanks for you suggestion :)
  • Admin
    Admin almost 11 years
    Sam! thanks for this trick, now i can save my time by leave emulator open.
  • Sam
    Sam almost 9 years
    I don't think the snapshot option actually does anything in Android Studio. I've tested it and seen no difference. That's probably because Android Studio doesn't seem to provide the option to launch an emulator from a snapshot or save one to a snapshot.
  • Sam
    Sam almost 9 years
    This looks pretty useful, especially if you have an SSD, but this question is tagged "Android Studio" rather than "Android Developer Tools".
  • RigidBody
    RigidBody about 7 years
    Thanks for that!!
  • Cold Cerberus
    Cold Cerberus over 3 years
    Can I do this with Android Studio's process too?