23

I create blank xamarin android project without add any code when i debug this project debugging without problem but when i run app with visual studio emulator for android emulator is running but not starting my app and deploy failed and don't show me error

why ? please help me

m.h.bayan
  • 281
  • 2
  • 3
  • 11

10 Answers10

49

I had the same issue. VS 2015 can launch the VS emulator but can't deploy the app.

I was able to solve the issue like this:

  1. Launch the emulator (F5 in VS, then cancel the deployment using the Build/Cancel menu)
  2. Click on the chevron icon (») in the toolbar to the right of the emulator
  3. Select the Network tab
  4. Locate the preferred network ip address
  5. Back in VS, click on the Open Adb Command Prompt toolbar button
  6. Type adb connect [the emulator ip address]
  7. Press F5 again in VS

Looks like a VS bug to me.

Saeb Amini
  • 23,054
  • 9
  • 78
  • 76
CSharpRocks
  • 6,791
  • 1
  • 21
  • 27
13

I had the same issue. It turned out the root cause was that the VS Emulator couldn't find adb.exe.

When that happens it won't connect to the emulator unless you do the manual connection following the steps CSharpRocks gives. The emulator also won't be listed under "adb devices".

The fix for me was to reinstall the Android SDK, using the Windows EXE based installer (not the zip installer). The EXE installer sets the HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Android SDK Tools key, Path value, in the registry, pointing to the Android SDK root directory.

The VS Emulator uses that registry setting (or the Android Studio install registry setting) to find the SDK, assuming you didn't install the Android SDK with Visual Studio itself. With that, it should be able to find adb.exe and work.

user1725145
  • 3,993
  • 2
  • 37
  • 58
  • 1
    This was the same method that suggested by Microsoft [(This is the link)](https://msdn.microsoft.com/en-us/library/mt228282.aspx#Anchor_8) and it worked for me and solved the issue permanently. – Json May 15 '17 at 15:12
8

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”
Community
  • 1
  • 1
Zverev Evgeniy
  • 3,643
  • 25
  • 42
4

I'm having a very similar issue. I have found two different kind-of-work-arounds, but have not yet figured out a full solution.

Start the emulator before trying to deploy to it

  1. Launch the Visual Studio Emulator for Android application from the start menu.

  2. Launch one of the available emulators via the green arrow

    Visual Studio Emulator for Android

  3. Attempt to again launch your application from visual studio, selecting the VS Emulator N-inch... emulator from the drop down menu

    Visual Studio Emulator List

For me for some reason the app still doesn't "launch" on the emulator, although it is installed. So I have to open the application menu and select my app. Additionally it will usually crash the first several times I try to open it, but eventually displays my single default label, Welcome to Xamarin Forms!.

Run the application in Ad-Hoc mode

  1. Before running the application, change the solution configuration (from the top toolbar next to the green "run" button) to Ad-Hoc.


The problem with both of these methods though is that I'm still not able to actually debug an application. I can run it, but my breakpoints are ignored and I think that will make finding bugs difficult once I actually start to write a real application.

I hope to update this answer once I figure out an actual solution.

Zach Olivare
  • 3,805
  • 3
  • 32
  • 45
  • Thanks so much - Starting the emulator before trying to deploy to it fixed it for me... – James May 21 '16 at 21:37
3

I had the same problem yesterday. The problem appeared (probably) because I tried to start development after a long break. I updated VS and everything, but faced many issues.

Eventually you need to start fresh

  1. Make sure SDK for emulator points to the right place (HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Android SDK Tools)
  2. Run Visual Studio with Administrator privileges
  3. Go to Hyper-V Manager and delete ALL Virtual Switches - let the system recreate them when needed. It will do it properly
  4. Delete all existing emulators and recreate them in Visual Studio. I even found a comment to name them without spaces - not sure if it is needed, but wouldn't hurt.

Doing all this helped me. But I was on the verge of reinstalling Windows 10 clean. I think lots of things and configuration changed and are no longer compatible.

Ivan Kirkorau
  • 635
  • 6
  • 11
0

Try it enabling Hyper-V and using a Visual Studio Emulator from android; that worked for me after a lot of attempts and research

Carlos Valdez
  • 129
  • 1
  • 10
0

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". This leaves a version of the app on the device which seems to block further attempts at debugging or deploying.

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

You could probably also manually start the emulator and say "wipe device" option so it starts fresh.

IamJohnny45
  • 43
  • 1
  • 7
0

In VS2017, on a Windows10 machine, all I had to do to get the app to show up was turn off Mobile Data. (swipe down or use settings, then click Mobile Data and confirm to turn it off).

After I turned it back on, I could access the app. Before doing this, it always seemed that the emulator ran, but wouldn't run the app.

... no idea why this worked, but I'm posting it here in case it helps someone.

During my troubleshooting process, I also looked at these articles:

msung
  • 3,562
  • 3
  • 19
  • 30
0

Install apache in VS 2015 here.
Visual studio requires apache to develop android apps.
You also may want to look at some other suggestions:
notshowing, troubleshooting

Yunnosch
  • 26,130
  • 9
  • 42
  • 54
-1

I had such issues before with the android SDK emulator, now I'm using Genymotion emulator instead of it, it is more light and faster and will be detected automatically by you VS once launched.

you can download the free version from here : https://www.genymotion.com/

and also you can download any device emulator.

MohamedHamza
  • 205
  • 1
  • 12