{"id":86,"date":"2014-02-04T17:39:32","date_gmt":"2014-02-04T17:39:32","guid":{"rendered":"http:\/\/visualgdb.com\/w\/?p=86"},"modified":"2015-07-19T08:35:33","modified_gmt":"2015-07-19T15:35:33","slug":"android-haxm","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/tutorials\/android\/haxm\/","title":{"rendered":"Accelerating your Android simulation using Intel HAXM"},"content":{"rendered":"<p>This tutorial shows how to significantly improve the performance of your virtual Android device by using hardware virtualization on an Intel CPU provided by the Intel Hardware Execution Manager (HAXM).<\/p>\n<ol>\n<li>First create a basic Android project. <a href=\"\/tutorials\/android\/\">Follow this tutorial to do this within Visual Studio.<\/a><\/li>\n<li>Download and install Intel HAXM. If you are using VisualGDB, this can be done using a shortcut in the Android Settings dialog (Android-&gt;Setup SDK\/NDK locations):<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/haxm\/01-installhaxm.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/haxm\/01-installhaxm.png\" alt=\"01-installhaxm\" width=\"640\" height=\"229\" \/><\/a><\/li>\n<li>Once HAXM is installed, you can start\/stop its service using Windows Service Manager or using the VisualGDB Android settings window:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/haxm\/02-haxminstalled.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/haxm\/02-haxminstalled.png\" alt=\"02-haxminstalled\" width=\"640\" height=\"229\" \/><\/a>Note that the HAXM service reserves certain amount of RAM while running. It is recommended to stop it when you don&#8217;t need it and start it again once you start your Android emulator.<\/li>\n<li>HAXM will only accelerate virtual Android devices that are based on the x86 platform. It won&#8217;t work\u00a0with ARM<br \/>\ndevices. To configure your project to use the x86 platform<br \/>\nplease create an Application.mk file inside the <strong>jni<\/strong> directory:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/haxm\/03-appmk.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/haxm\/03-appmk.png\" alt=\"03-appmk\" width=\"700\" height=\"394\" \/><\/a><\/li>\n<li>Add the following text to the Application.mk file:\n<pre>APP_ABI := x86<\/pre>\n<\/li>\n<li>Rebuild your project. You will see the x86 compilation taking place in the log file: <a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/haxm\/04-abi.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/haxm\/04-abi.png\" alt=\"04-abi\" width=\"684\" height=\"800\" \/><\/a><\/li>\n<li>Now we will create a new virtual Android device accelerated by HAXM. Open AVD Manager and click &#8220;New&#8230;&#8221;. Select &#8220;Galaxy Nexus&#8221; as the device and &#8220;Intel Atom (x86)&#8221; as the CPU: <a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/haxm\/05-newavd.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/haxm\/05-newavd.png\" alt=\"05-newavd\" width=\"414\" height=\"658\" \/><\/a><\/li>\n<li>Observe the emulator startup log. It should mention that the acceleration is working properly:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/haxm\/06-haxworking.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/haxm\/06-haxworking.png\" alt=\"06-haxworking\" width=\"450\" height=\"300\" \/><\/a><\/li>\n<li>You will notice how fast the emulated device starts up. Go back to Visual Studio and press F5 to launch your project. VisualGDB will setup the debugging session automatically:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/haxm\/07-deploy.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/haxm\/07-deploy.png\" alt=\"07-deploy\" width=\"484\" height=\"358\" \/><\/a><\/li>\n<li>Set a breakpoint inside your native code. Interact with the app so that the breakpoint is triggered:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/haxm\/08-breakpoint.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-8\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/haxm\/08-breakpoint.png\" alt=\"08-breakpoint\" width=\"684\" height=\"800\" \/><\/a><\/li>\n<li>You will notice a significant increase in debugger performance compared to the virtual ARM devices. Other aspects of the emulation will remain the same:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/haxm\/09-emulator.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-9\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/haxm\/09-emulator.png\" alt=\"09-emulator\" width=\"700\" height=\"951\" \/><\/a><\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to significantly improve the performance of your virtual Android device by using hardware virtualization on an<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[31],"_links":{"self":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/86"}],"collection":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/comments?post=86"}],"version-history":[{"count":1,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/86\/revisions"}],"predecessor-version":[{"id":188,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/86\/revisions\/188"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=86"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=86"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=86"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}