6

I am new to Xamarin. I used Xamarin. Forms template to create a sample mobile solution in Visual Studio 2017. The process created four projects Xamarin PCL, Xamarin Android, Xamarin.iOS and Xamarin.UWP. Without making any modification to the generated solution, I am trying to run it.

The first issue is, when I set the UWP as the starting project, the Windows emulator shows up and runs the app perfectly. But when I try to do the same with Android, I get different errors at different times based on the environment changes I make. Finally, using the visual studio android emulator, the Phone UI shows up but not my app. In the background, I can see that Visual Studio completed the build process successfully without any errors but the deploy process simply hangs. I left the deploy running overnight but still running in the morning. Here is my environment.

  • Intel Core i7 processor
  • Virtualization enabled in BIOS
  • Windows 10 Education
  • 32GB RAM
  • Hyper-V disabled in Windows
  • Executed bcdedit /set hypervisorlaunchtype off in the command window and rebooted.

I tried setting the above environment in different combinations but none of them seem to make the app work. When I use an android emulator from android SDK, the build process throws errors. The only emulator that even builds is the visual studio emulator. But the deploy hangs.

A second issue I have is, I have installed android SDK for version 24 and 25. But in the emulator dropdown, I can only see the emulators for 23. I checked the installation path both in visual studio and android SDK manager and they both point to the same installation folder. What do I need to make the emulators for version 24 and 25 usable?

I repeat, I did not make any change to the generated solution in visual studio before running it. I have been at it for the past three days and couldn't make it work. Please help.

5
  • Check the project options for your Droid project. It has API levels that are supported. Make sure 24 and 25 are supported, otherwise you will not be able to run it on that emulator (or devices for that matter). Apr 11, 2017 at 11:09
  • 3
    Both the windows emulator (as opposed to the simulator) and the visual studio android emulator actually require hyper-v, so you don't want to have that disabled. The reason you might have seen advice to turn off hyper-v is to enable virtualbox-based emulators, but Microsoft's use hyper-v. So I would enable that and make sure you can run them. For UWP apps, the default will be to run in the simulator, which is just the windows desktop in another window. The emulator is for windows phone. Oh, and Microsoft doesn't have api 24 or 25 emulator images yet, but 23 is fine for most things. Apr 11, 2017 at 23:01
  • @BenReierson Thanks for the info. I had already tried with Hyper-V both on and off. Another point here is : In my Android SDK Manager under Extras, Entel x86 Emulator Aceelerator (HAXM Installer) ver 6.1.1 is marked with a status "Not compatible with Windows. I read in many posts this could be the problem too. But I have no clue how to get the HAXM installed. I think I forgot to mention this in my original post. Apr 12, 2017 at 19:16
  • You might want to check the ConfigurationManager, and make sure that the Deploy options for the Android project is ticked. It happens to me when I try to build and deploy a working solution(from VS2015) in VS2017.
    – Frankie
    Apr 13, 2017 at 20:54
  • @Frankie : Thanks Frankie. I checked my deploy option for the Android Project and it is already ticked. The problem still persists. Apr 14, 2017 at 14:51

2 Answers 2

7

I just installed Visual Studio 2017 (on Win10 15063.138) and found, like you, Xamarin projects won't deploy to Android. Here's how I got running:

  • Updated everything in the Android SDK Manager.
  • Installed the new, improved Android Emulator from MS: https://www.visualstudio.com/vs/msft-android-emulator/
  • Used that to download/install an API level 23 (6.0 Marshmallow) emulator
  • Started that emulator using the same tool (you'll see it running in Hyper-V Manager)
  • Selected same emulator in VS for deploy/debug (the emulators that ship with VS are painfully slow)
  • In VS, selected Android project for start-up and verified build and deploy to Android in build config mgr.

Note: MS doesn't appear to have any emulators above API level 23, so Compilation and Target settings for your Android project can be the latest, but the minimum target will have to be 6.0 (API 23).

1
  • Thanks for your suggestions. I followed your suggestions exactly point by point. For a second I thought I got it. But it was short-lived. The debug process started with a lot of messages in the output window over the course of the build and deploy all the while the emulator was showing the home screen of an android phone. When the deploy completed, a white screen (apparently my application) appeared for a fraction of a second, I couldn't even see the test message. The debug stopped abruptly without any error message. Any idea? Apr 20, 2017 at 14:32
5

After pulling my hair for the past few days, I finally got my Xamarin.Forms Android App to show my page on the emulator. Thanks to all the members for their suggestions. Ryan's suggestion helped a lot ( I +1ed him, thanks Ryan) but did not solve my problem. I googled further and found a suggestion that asked to change the following setting which did it for me finally. So, if anyone else get stuck like I did, please do the following (in addition to cleaning up and updating all packages):

  • Open up the setting for your Hyper-V vm for your emulator (while the VM is off).
  • Expand the Processor node on the left and click on "Compatibility".
  • Now put a check mark on "Migrate to a physical computer with a different processor version" on the right.
  • Start your emulator in the Visual Studio Emulator tool.
  • Now, start debug your android project in VS using the same emulator that is already running.
  • After a delay (there is always a delay), your app will show up on the emulator. Yey!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.