Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Mobile

How To Make Android Studio Really Fast On A Windows PC

4.78/5 (19 votes)
4 Aug 2014CPOL8 min read 137.8K  
Article #2 - How To Make Android Studio Really Fast On A Windows PC

Introduction

Android Studio is a powerful feature rich design environment.  However, unassisted, it can frequently be very sluggish on many Windows PCs.  This article shows you how to take advantage of the Intel Virtualization Technology extensions to make it really fast and a lot more fun to use.

Background

A basic background in setting up a Windows 8 PC is all that is required to follow this article.  You must have administrator privileges on the PC to use this tutorial. 

The Problem with Emulators

An emulator is an intricate software package that is frequently used to emulate a hardware device.  It makes writing software for a target device easier and faster because you can work directly on your PC instead of having to transfer code to the device for each iteration of your app.  Android Studio uses the open source QEMU package to emulate various hardware devices.  Emulators like QEMU translate the code you create for the target device into byte code your PC can execute.  However, this translation takes time and without hardware assistance it can be a relatively slow operation.

Intel Virtualization Technology (IVT)

Most modern Intel based motherboards support Intel's Virtualization Technology (IVT).  IVT provides special facilities to programs written to take advantage of them that make software like emulators execute much faster.   For example, without IVT Android Studio takes several minutes to load up on my ASUS motherboard that has an Intel i5 quad core processor and 8 GB of RAM.  With IVT enabled it takes only 30 seconds, and the IDE  performs much faster.

Intel Processor Identification Utility (IPI)

Before you get started, there is a free utility available from Intel that you should download and run called the Intel Processor Identification utility (IPI).  It will tell you if your CPU supports IVT and also give you a wealth of other information about it.  Here is what the utility shows for my system when you select the CPU Technologies tab:

Image 1

As you can see, both Intel Virtualization Technology and Intel VT-x are enabled indicating that my system is currently set up to support IVT fully.  However, that is because I took special steps to enable IVT.  Your system most likely will show those two features as being disabled.

The Fly In The Ointment

There is a wrinkle that makes setting up IVT more complicated than it normally would be.  Some Windows apps and games use Intel's Hypervisor technology to operate properly and some won't operate at all without it like the Windows Phone emulators used in Windows Phone development.  This is a problem because Hypervisor and IVT are not compatible!  In other words, to have one turned on mandates that the other is turned off.  Since Hypervisor is usually turned on by default you will find usually that IVT is not turned on when you run the IPI utility.  Therefore, simply going into your BIOS and enabling IVT is usually not enough to to turn on IVT.  The solution?  You need to set up separate boot profiles like I have, one for Hypervisor and one for IVT.  This is a fairly straight-forward procedure but only if you have certain key, yet hard-to-find critical information available to you.  Fortunately this article lays out the steps for you to make it easy.  

Step 1 - Setting Up A Boot Profile For Android Studio

In older versions of Windows setting up multiple boot profiles was easier because it was a simple manner of editing a special system file using a text editor.  In Windows 8, you have to use an obscure system utility called bcdedit.  

NOTE: Be careful while editing your boot file or you may render your system inoperable!  Use this information at your own risk!

First, open a command prompt with elevated command privileges:

Image 2

Enter the following command to see what boot profiles you currently have set up:

Quote:

bcdedit /enum /v

This tells bcdedit to list all the entries in the boot file in verbose mode.  Here is my configuration.  

Image 3

Ignore the entry with the description "Windows Boot Manager".  As you can see I have two entries:

  • Windows 8.1
  • Windows 8.1 for Android

Those are the two choices presented to me when I boot my system.  I use the first choice when I need Hypervisor, for when I do Windows Phone development.  I use the second choice when I need IVT, for when I do Android Studio development. If you haven't modified it, you will only see an entry for Windows 8.1 when you list your boot file contents.

The only difference between my two boot entries is the status of the hypervisorlaunchtype key.  When I do Windows development work the value of that key is Auto so that Hypervisor is turned on, which disables IVT.  When I do Android development the value of that key is Off, disabling Hypervisor and thus allowing IVT to be enabled.

The most painless way to create a new boot profile is to copy the existing boot profile for Windows 8.1 and then modify the value of the hypervisorlaunchtype key.  Execute these simple steps to do that, but do it carefully:

  • Using the command prompt edit facilities, highlight and copy to the clipboard the identifier for the Windows 8.1 entry.  For example, as you can see from the listing above my Windows 8.1 entry identifier is {c425d97b-5abe-11e3-9eec-cccc56525e2c}. Make sure you include the curly braces!
  • Build the bcdedit copy command by pasting in your Windows 8.1 identifier (guid) so it looks like the following:

    bcdedit /copy {YOUR WINDOWS 8.1 IDENTIFIER} /d "Windows 8.1 for Android"

    Hit Enter to execute it.  This will create a duplicate of your Windows 8.1 entry with the description "Windows 8.1 for Android" but with its own identifier.
  • Execute the command to list your boot profile contents again.  You should see your new boot profile entry.
  • Highlight and copy to the clipboard the identifier of your new Windows 8.1 for Android boot profile entry.
  • Build the bcdedit command to disable Hypervisor for your new boot profile entry as follows: 

    bcdedit /set {WINDOWS 8.1 FOR ANDROID IDENTIFIER} hypervisorlaunchtype Off

    Insert the identifier for your Windows 8.1 for Android boot entry where indicated.
  • Execute the command to list your boot profile contents again.  Make sure that the hypervisorlaunchtype key is indeed set to Off.

Congratulations!  You know have two boot profiles, one for using your Windows PC with Hypervisor and one for doing Android Studio development with IVT enabled.

Step 2 - Enabling IVT in the BIOS

You need to make sure that IVT is enabled in your BIOS.  Every BIOS is a little different so I can't give you exact instructions.  However, all you need to look for are the terms Intel Virtualization Technology and Intel VT-x.  You should see one or the other used in your BIOS setup screen.  Reboot your system and enter BIOS setup.  Look around until you find settings for the above terms.  You will typically find them under a menu entry such as CPU, Advanced Settings, or O/S Features, etc.  Make sure any relevant entries you find are set to "On" or "Enabled".  

Important: After saving the changes to your BIOS you will need to power down your system to "make the changes stick"!  Do this and then power your system on again.  When you do, you will be presented with a screen asking you to choose a boot profile.  Make sure you select the new one you just created titled "Windows 8.1 for Android".

Step 3 - Setting Up the Intel x86 Emulator Accelerator

The last piece of the puzzle is to install the Intel x86 Emulator Accelerator package into Android Studio.  This will add the extensions necessary for Android Studio to make use of IVT leading to much faster, smoother operation of the IDE and device emulator(s).

Follow these simple steps:

  • Run the IPI utility above to make sure IVT is fully enabled.  If not, you will need to diagnose and fix that problem first because the HAXM Installer will not run if IVT is not enabled.
  • Run Android Studio.
  • Make sure you install any recommended updates to Android Studio first!
  • Load the Android SDK Manager.  Under the Package folder labeled Extras, look for the Intel x86 Emulator Accelerator (HAXM Installer) package (see graphic below).

    Image 4
     
  • Check the box for that package and install it.  This does not actually install the extensions.  Instead it downloads the HAXM Installer to a directory on your hard disk.
  • Locate the HAXM installer on your hard disk.  On my PC it was installed into the following directory:

    C:\Users\Robert\AppData\Local\Android\android-studio\sdk\extras\intel\Hardware_Accelerated_Execution_Manager
     
  • Run the utility named intelhaxm.exe and follow the steps.

Although it may not be necessary, it's not a bad idea to reboot your system now or at least exit and reload Android Studio.

Step 4 - Success!

You have now set up Android Studio to take advantage of IVT.  You should see a dramatic difference in the time it takes to start up Android Studio and the debugger, and a significant improvement in IDE and code tracing operations.  Remember, when you want to run an app that requires Hypervisor support you will need to reboot your system and select the Windows for 8.1 boot profile from the list of choices instead of the Windows 8.1 for Android choice.

 

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)