How can I attach a virtual device/emulator to Visual Studio Xamarin Android project?

B. Clay Shannon-B. Crow Raven picture B. Clay Shannon-B. Crow Raven · Mar 20, 2014 · Viewed 13.6k times · Source

I created an Android app for Ice Cream Sandwich and added nothing to the default code (except changing the text of the "Hello World" message - I couldn't - or wouldn't - help myself).

I mashed F5.

Nada - no device attached. The dropdown list says "No Devices Attached."

So, I set one up via the "Open Android Emulator Manager" button that the Xamarin install added:

enter image description here

I mashed F5 again; same problem. It said to pick a device from the dropdown list (I had forgotten to explicitly choose the one I just set up). But...there's nothing in the list. Why not?

UPDATE

It's working now; I reckon it was not showing me my device for selection because some Android packages were downloading in the background (via the "Android SDK Manager", also added by Xamarin).

I feel transported back two years, when I was "messing around with" Eclipse/Android/Java.

Answer

Adam picture Adam · Mar 28, 2014

Awesome that you got it working.

I found that list doesnt always update and a restart of Visual Studio was the quickest way to get the emulator in the list of devices to debug against.

If that doesnt work, try restarting the ADB service.

  • Start the emulator.
  • Open up a command prompt, browse to the location of the Android SDK (default is '%LocalAppData%\Android\android-sdk\platform-tools').
  • Run the command 'adb kill-server'.
  • Run 'adb devices' (this should show the running emulator as an attached device).
  • Restart VS and you should see the emulator in the list.