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

8

7

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.

Olivarez answered 8/3, 2016 at 9:39 Comment(5)
How long have you waited? In my experience deploying to an emulator can take a really, really long timeDanais
@Danais The maximum time is about 20-30 minutes,I think this is abnormal.Olivarez
The emulators that come from android are just terrible. They're slow and if you give them too much ram they often fail in weird ways. I'd recommend trying this on genymotion emulators. They have a free version on their site that's a bit hard to find, but after using them you won't be able to go back.Type
I have no problem with emulator speed. Microsoft emulator is really really fast. It boots up in a few second. My Problem is only about deploying my app for debugging in emulator.Olivarez
In addition, I am using this emulator on my laptop without any problems.The only difference between my desktop and my laptop is versions of windows. in my laptop I'm using windows 10 build 10586 version 1511 but my desktop is not updated.Olivarez
F
11

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.)

Fiddler answered 2/7, 2016 at 11:7 Comment(1)
Not sure if it is mandatory but I also had to add backslash `\` at the end of the path.Similitude
Q
1

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.

Quartile answered 8/12, 2016 at 16:16 Comment(0)
T
1

I had the same issue. After a long struggle i fixed it.

Sol 1 :

Check with the registry as mentioned by others.

 **HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Android SDK Tools**

Sol 2 :

In my case there is no android-SDK tool found in registry. So you have to add the registry manually here "**HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node**"

you can add it by right click on **Wow6432Node** => **New** => **key**.

Set Key name as **"Android SDK Tools"**then right click on **Android SDK Tools** =>**New** => **String Value**

Set Name as **Path** for newly added string. Then right click on **Path** => **Modify..**

Copy the Android SDK Tools path from program files and paste in Value Data.

Now the registry is created manually. You can debug the project via emulator.

Note : Don't forgot to restart the system.

Tearoom answered 13/11, 2017 at 7:28 Comment(0)
B
0

Have a look here:

Xamarin Forms Android App Crashes Running Debug with VS Android Emulator

  1. Start the Hyper-V manager
  2. Select the emulator you are trying to use
  3. Right-click, hit settings
  4. Click processor
  5. Click Compatibility
  6. Set checkbox “Migrate to a physical computer with a different processor version”

You do not have this issue on a laptop because its processor does not provide the new features which are unsupported by the Android Emulator for Visual Studio. The described tweak is only needed on PCs with newer CPUs.

Brobdingnagian answered 13/5, 2016 at 17:38 Comment(0)
S
0

I got round this problem by starting Visual Studio as an administrator.

Schmit answered 24/5, 2016 at 7:44 Comment(0)
A
0

I too have had weirdness with the Visual Studio Emulator for Android and visual studio appearing to be stuck at the "Deploying ..." step trying to launch the app for debugging. What I discovered is that restarting both the emulator and visual studio seems to make things better for me once it starts to do this. Also, when debugging an app, it seems that exiting your app normally helps compared to when using the "Stop Debugging" button. For example, I started my app twice and killed it w/ the "Stop Debugging" button, but couldn't deploy/start the app a 3rd time w/out a restart of visual studio and the emulator. Am using VS 2015 Community edition w/ update 3.

Atmospherics answered 2/2, 2017 at 21:30 Comment(0)
I
0

I just had a very interesting experience,

In my case the registry path to SDK was correct,

I had unchecked the "Use Fast Deployment" (under packaging properties in android options), and all my efforts to reboot the PC, close VS, Close Emulator start over had failed.

However I did these two:

1 - Updated all the components in android SDK manager and restarted the PC,

2 - Disabled my anti-virus! and then suddenly VS deployed the app to the emulator!! (It was stuck in the same situation where the emulator starts and nothing happens!, I did this out of despair!)

(OS: win 7, professional, VS 2017 Community edition!)


More Details

I have been trying this for three more days For my special case disabling the Anti Virus seems to solve the issue every single time!

Instalment answered 18/4, 2017 at 19:57 Comment(0)
D
0

The solution for me was to Check the deploy box in the Configuration ManagerTurn on Deploy

This answer came from Xamarin Forum

Drenthe answered 8/9, 2017 at 16:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.