Visual Studio Emulator for Android asking for HAXM instead of Hyper-V?

icelavaicelava USMember ✭✭

I am learning cross platform mobile app development for the first time and a few days ago had been struggling to get Visual Studio 2017 to deploy properly to ADV emulator. It was way too slow, unresponsive, and stall Visual Studio into a busy/wait state that require abrupt termination of the devenv.exe process even after closing the emulator.

That was the short summarised story; the long story with all the details and errors was submitted in another post (24 Oct) which for some reason got stuck in some moderation vacuum and hasn't appeared in this forum again.

ADD NOTE: It seems editing posts for typing mistakes sends them to some hidden place. So I've had to re-post this question.

Anyway, I understood a large contributor to the slow performance is the lack of Intel HAXM to accelerate the emulated device. Since I have Hyper-V running (on this Surface Pro 4) and that appears to be mutually incompatible with HAXM. Also I believe even with HAXM available it would only boost Intel Atom x86 virtual devices? ARM-based devices would still run punctured, and my target device was ARM.

But eventually I got around to learn that Visual Studio has its own emulator for Android separate from the default Android SDK emulator, which utilises Hyper-V. I looked at the installer options and sure enough it was there, so I checked it in. On re-launching VS2017 I saw that it added four more new target VisualStudio-based Android devices for my Xamarin.Android project. I tested a deploy to one of those devices and then a similar warning popped up

VisualStudio_android-23_x86_phone will run unaccelerated

This emulator does not have hardware acceleration enabled, and its performance will be impacted. We recommend to either:

  • Enable hardware acceleration on this machine by installing Intel© HAXM and disabling Hyper-V (requires a system restart).

I am confused what's happening here; isn't the Visual Studio Emulator for Android supposed to use Hyper-V?

Also when I check out the new Tools > Visual Studio Emulator for Android... option I can only see device profiles up to API level 23. No option for level 24/25?

Best Answer

  • icelavaicelava US ✭✭
    Accepted Answer

    @AaronSeet said:
    Unsure what is really happening between the various attempts....

    Apparently my Surface Pro 4 using an Intel Skylake processor induces some incompatibility problem, and needs a tweak to the VM settings for the debugger to attach properly.

    https :// docs.microsoft.com/en-us/visualstudio/cross-platform/troubleshooting-the-visual-studio-emulator-for-android#Skylake

    Still, finding it odd there are no Nougat API level 24/25 available for device profiles.....

Answers

  • icelavaicelava USMember ✭✭

    And for some reason while lurking in the Xamarin.Android forum and trying to sort all that forum behaviour out, this post ended up in Xamarin.Forms forum. Wow.... I think I'm just gonna leave it alone since and edit work is likely to zap the post in some hidden space again.

  • icelavaicelava USMember ✭✭

    So apparently those "VisualStudio" devices were not from Visual Studio Emulator for Android but part of the stock Android SDK ADV emulator set. I don't know why but the target list never update until added some Marshmallow (6.0.0) profiles in Visual Studio Emulator for Android window. Only then did new target devices appear and I was able to launch a Hyper-V based device.

    Unfortunately the code deployment or virtual device process sent the CPU wild 100% and blue-screen crashed the computer, leaving me to restart the entire system to a desktop with re-arranged icons.

    Tried it a second time to the same 5.7" Marshmallow (6.0.0) XHDPI Phone (Android 6.0 - API 23) device, it seemed to run without crashing this time but after deploying to the device, the debugger activated for a brief moment then dropped off and stopped completely. The Output window stated

    Android application is debugging.
    Couldn't connect to logcat, GetProcessId returned: 0

    Tried a third time

    Android application is debugging.
    Could not connect to the debugger.
    10-28 20:56:56.814 I/art ( 3737): Late-enabling -Xcheck:jni
    10-28 20:56:57.196 W/monodroid( 3737): Creating public update directory: /data/user/0/com.companyname.PlanetaryApp/files/.__override__
    10-28 20:56:57.197 W/monodroid( 3737): Using override path: /data/user/0/com.companyname.PlanetaryApp/files/.override
    10-28 20:56:57.198 W/monodroid( 3737): Using override path: /storage/emulated/0/Android/data/com.companyname.PlanetaryApp/files/.override
    10-28 20:56:57.198 W/monodroid( 3737): Trying to load sgen from: /data/user/0/com.companyname.PlanetaryApp/files/.override/libmonosgen-2.0.so
    10-28 20:56:57.198 W/monodroid( 3737): Trying to load sgen from: /storage/emulated/0/Android/data/com.companyname.PlanetaryApp/files/.override/libmonosgen-2.0.so
    10-28 20:56:57.198 W/monodroid( 3737): Trying to load sgen from: /storage/emulated/0/../legacy/Android/data/com.companyname.PlanetaryApp/files/.override/libmonosgen-2.0.so
    10-28 20:56:57.198 W/monodroid( 3737): Trying to load sgen from: /data/app/com.companyname.PlanetaryApp-1/lib/x86/libmonosgen-2.0.so
    10-28 20:56:57.200 W/monodroid( 3737): Trying to load sgen from: /data/user/0/com.companyname.PlanetaryApp/files/.override/links/libmonosgen-2.0.so
    10-28 20:56:57.205 W/monodroid-debug( 3737): Trying to initialize the debugger with options: --debugger-agent=transport=dt_socket,loglevel=0,address=127.0.0.1:29238,server=y,embedding=1
    10-28 20:56:57.234 W/monodroid-debug( 3737): Accepted stdout connection: 11
    10-28 20:56:58.007 D/Mono ( 3737): Image addref mscorlib[0xab6b5840] -> mscorlib.dll[0xad06ba00]: 2
    10-28 20:56:58.011 D/Mono ( 3737): Prepared to set up assembly 'mscorlib' (mscorlib.dll)
    10-28 20:56:58.012 D/Mono ( 3737): AOT: image 'mscorlib.dll.so' not found: dlopen failed: library "/data/app/com.companyname.PlanetaryApp-1/lib/x86/libaot-mscorlib.dll.so" not found
    10-28 20:56:58.012 D/Mono ( 3737): AOT: image '/usr/local/lib/mono/aot-cache/x86/mscorlib.dll.so' not found: dlopen failed: library "/data/app/com.companyname.PlanetaryApp-1/lib/x86/libaot-mscorlib.dll.so" not found
    10-28 20:56:58.012 D/Mono ( 3737): Config attempting to parse: 'mscorlib.dll.config'.
    10-28 20:56:58.012 D/Mono ( 3737): Config attempting to parse: '/usr/local/etc/mono/assemblies/mscorlib/mscorlib.config'.
    10-28 20:56:58.031 D/Mono ( 3737): Assembly mscorlib[0xab6b5840] added to domain RootDomain, ref_count=1

    Unsure what is really happening between the various attempts....

  • icelavaicelava USMember ✭✭
    Accepted Answer

    @AaronSeet said:
    Unsure what is really happening between the various attempts....

    Apparently my Surface Pro 4 using an Intel Skylake processor induces some incompatibility problem, and needs a tweak to the VM settings for the debugger to attach properly.

    https :// docs.microsoft.com/en-us/visualstudio/cross-platform/troubleshooting-the-visual-studio-emulator-for-android#Skylake

    Still, finding it odd there are no Nougat API level 24/25 available for device profiles.....

  • voidstreamvoidstream FRMember ✭✭✭
    • Launch "Visual Studio Installer"
    • Edit
    • Individual components tab
    • Search emulator for visual studio for android

  • icelavaicelava USMember ✭✭
    edited October 2017

    Hi voidstream, I've already done that first step (which in itself didn't present any problem). The difficulties extend way beyond that stage.

  • PrinceHoffJrPrinceHoffJr USMember ✭✭

    did u ever find a solution to your emulator issue. i am having a hell of a time. super super super super SLOW

  • avillarubiaavillarubia Member ✭✭

    this xamarin is very painful in the ass, someone can help this thread?

  • avillarubiaavillarubia Member ✭✭

    try download HAXM here:
    https://software.intel.com/en-us/articles/intel-hardware-accelerated-execution-manager-intel-haxm

    and disable Hyper-V here:
    on windows icon on your keyboard type: windows features
    locate Hyper-V and remove

  • icelavaicelava USMember ✭✭

    @PrinceHoffJr the solution for my processor generation (Skylake) was to adjust the Hyper-V virtual machine settings to make debugging compatible.

  • icelavaicelava USMember ✭✭

    @avillarubia removing Hyper-V in order to run HAXM is problematic if one is already utilising Hyper-V for other virtualisation purposes. Anyway I managed to run Android virtual devices in Hyper-V.

    The only massive pity is Microsoft actually stopped supporting its own Visual Studio emulator in favour of Android's own stock SDK emulator. That is why there are (annoyingly) no additional API levels available beyond that.

  • PrinceHoffJrPrinceHoffJr USMember ✭✭

    what adjustments to HyperV did you make? Which emulator should I be using?

  • GiampaoloGabbaGiampaoloGabba USMember ✭✭✭

    Google android emulation with HAXM is the best option available.
    If you cant use HAXM (i.e. amd processor) or cant get rid of HyperV you can try Genymotion.

    Its free for personal use: https://www.genymotion.com/fun-zone/

    I personally use vmware for standard emulation and Google AVDs with HAXM for Android.

  • icelavaicelava USMember ✭✭

    @PrinceHoffJr said:
    what adjustments to HyperV did you make? Which emulator should I be using?

    Check out the MSDN link I referenced above as answer.

  • PrinceHoffJrPrinceHoffJr USMember ✭✭

    thanks. I will.

Sign In or Register to comment.