Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xamarin.Android Projects failed to deploy in visual studio emulator for android

I'm using visual studio 2015 update 1 with windows 10 build 10586 TH1.

also I'm using Xamarin Version 4.0.1.96.

I have created a blank Xamarin.Forms app. It deploys to Windows Phone emulators without any issue. But unable to deploy to Android Emulators.

When I start android project Android Emulator launched successfully but visual studio freeze at this step.

I've tried a lot of android emulator profiles but cannot solve the problem.

This problem only exists for Emulators and project successfully deployed on physical android device.

I have the same issue with Xamarin.Android projects.

Here is all of the text in output window:

  • 1>Starting deploy 4.5" KitKat (4.4) HDPI Phone ...
  • 1>Starting emulator 4.5" KitKat (4.4) HDPI Phone ...
  • 1>Validating emulator arguments...
  • 1>Determining if emulator is already running...
  • 1>Preparing virtual machine...
  • 1>Launching emulator...
  • 1>Emulator launched successfully

Thank you in advance for your help.

like image 360
armin rasolian Avatar asked Mar 08 '16 09:03

armin rasolian


2 Answers

I was running into the same issue with the emulator starting up find but Visual Studio getting hung on the build/deploy. Finally figured it out from here.

Visual Studio gets stuck trying to deploy the app to the emulator or the emulator does not appear as a debug target in other IDEs

If the emulator is running, but it does not appear to be connected to ADB (Android Debug Bridge) or it does not appear in Android tools that make use of ADB (for example, Android Studio or Eclipse), you may need to adjust where the emulator looks for ADB. The emulator uses a registry key to identify the base location of your Android SDK, and looks for the \platform-tools\adb.exe file under that directory. To modify the Android SDK path used by the emulator:

  • Open Registry Editor by selecting Run from the Start buttons context menu, typing regedit in the dialog box, and choosing OK.
  • Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Android SDK Tools in the folder tree on the left.
  • Modify the Path registry variable to match the path to your Android SDK. Restart the emulator and you should now be able to see the emulator connected to ADB and associated Android tools.

The value in my registry was set to "C:\Program Files (x86)\Android\android_sdk" (or similar). Updating it to "C:\Users\{USERNAME}\AppData\Local\Xamarin\MonoForAndroid\AndroidSDK" solved it for me. (I haven't yet worried about how to make this work for all users.)

like image 106
daveidmx Avatar answered Sep 27 '22 19:09

daveidmx


I had the same issue but in my case it was not the registry. After doing a release build, I deployed the app to the emulator device in release mode which pushes the app to the device and then effectively "disconnects". These leaves a version of the app on the device which seems to block further attempts at debugging.

I solved it by starting the emulator, going to "settings -> apps" and manually uninstalling my app. Then the next debug build & deploy worked again.

like image 31
IamJohnny45 Avatar answered Sep 27 '22 17:09

IamJohnny45