Bengi Besceli
Bengi Besceli

Reputation: 3748

How can I debug Visual Studio - Xamarin.Forms project on Android device?

I want to attach the Android device to Windows 8.1 trough USB instead of using the built in emulator.

How can I do this?

Note : The device can be connected trough USB (USB drivers are installed),
and its in devaloper mode.

Upvotes: 0

Views: 964

Answers (2)

SushiHangover
SushiHangover

Reputation: 74094

  • You first need to enable Developer Mode:

Android 4.2 and higher

Starting in Android 4.2 and higher, the Developer options is hidden by default. To make it available, go to Settings > About phone, and tap the Build number item seven times to reveal the Developer Options tab:

Xamarin's doc: Set Up Device for Development

  • Then you need USB drivers for your phone if you already do not have them installed, check Sony's support site.

Once your device is connected to your machine via the USB cable, debugging is just like debugging via an emulator.

Start debugging your application by pressing Cmd-Enter in Xamarin Studio on OS X or F5 in Visual Studio. When you do so, you may be prompted to choose the device to debug with.

Xamarin's doc: Debug on Device

Check that your device is showing up for Android's adb:

1) Find where Visual Studio/Xamarin (or you) installed the Android SDK:

(Click 'Tools' in the toolbar at the top, then click 'Options')

enter image description here

2) Copy the the path for Android SDK Location

3) Paste that into your shell (cmd or powershell) proceeded by cd (we need to change to that directory.

4) CD into the platform-tools subdirectory

5) Run adb devices

This should display something like:

List of devices attached
XXX12345    device

If all that is returned:

List of devices attached

Then the device is not been recognized and will not be available for Xamarin (or any of the Google Android tools) to deploy.

Note: Also check to ensure that your phone is in Mass Storage mode, as some default to MTP mode and that will not work as an adb device

Note: If it’s NOT appearing in the list make sure that drivers are properly installed and you’ve enabled “USB Debugging" on the phone

Upvotes: 1

Giorgi
Giorgi

Reputation: 30873

You need to enable USB debugging in Developer Options in your phone, plug your phone and it should be detected by Visual Studio.

You may also need to download and install USB Drivers from Sony Drivers page

Upvotes: 1

Related Questions