0

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.

Bengi Besçeli
  • 3,638
  • 12
  • 53
  • 87

2 Answers2

1

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

Giorgi
  • 30,270
  • 13
  • 89
  • 125
1
  • 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

SushiHangover
  • 73,120
  • 10
  • 106
  • 165
  • How can I do this on Visual Studio? – Bengi Besçeli Apr 18 '16 at 07:13
  • The link in my answer shows both Visual Studio and Xamarin Studio steps with screen shots : https://developer.xamarin.com/guides/android/deployment,_testing,_and_metrics/debug-on-device/ – SushiHangover Apr 18 '16 at 07:15
  • Thanks for the link but I couldn't done. There is written on the page as "First, make sure the debug configuration has been set, to allow you access to the debug tools", but there is not a debug options opitions on my Visual Studio. (I didn't install USB drivers because I could be able to connect the device to Windows trough USB, it detected). What do I miss? I couldn't see the device on the debug menu. So I cannot select my device to debug. – Bengi Besçeli Apr 18 '16 at 08:06
  • Make sure that your device is showing up for Android's adb. If it shows up there, it will show up for Xamarin. `adb.exe devices` If it does not show in that the list (under `List of devices attached`) then the USB drivers are not the correct ones and/or the phone is not in developer's mode http://developer.android.com/tools/help/adb.html – SushiHangover Apr 18 '16 at 08:22
  • I checked amd.exe using cmd.exe and listed by typing amd.exe devices -l. But it said "amd server is out of date. killing... amd server didn't ACK * failed to start daemon *" (My device is in developer mode) – Bengi Besçeli Apr 18 '16 at 09:25
  • Not `amd.exe`, but `ADB.exe`. You will find it in your Android SDK install location under the platform-tools directory – SushiHangover Apr 18 '16 at 09:27
  • Okey, I wanted to write adb.exe – Bengi Besçeli Apr 18 '16 at 09:28
  • ? What is the output that `adb devices` is giving you? It should not be "amd server is out of date. killing... amd server didn't ACK" but something like : `List of devices attached`... – SushiHangover Apr 18 '16 at 09:43
  • Hmm actually I don't know how can I run adb.exe. I have searched adb.exe on C and found 2 exe's. One is 4,16 MB and in my Xamarin Android Player folder that I have installed, and the other is 922 KB which is on the default Xamarin-SDK folder. I tried one; when I called amd on cmd, it gets the help. So checked the help and called amb devices -l. I may be doing wrong, as I say, how could I get the `list of devices attached`? – Bengi Besçeli Apr 18 '16 at 09:57
  • 1
    @mrbengi : I update my answer with additional steps to help you through the steps. See if that help you – SushiHangover Apr 18 '16 at 10:07
  • Thanks I checked and it gets "List of devices attached" and the list is empty. – Bengi Besçeli Apr 18 '16 at 10:31
  • Since you should said you enabled developer mode, then either the cable you are using is not a complete data cable but just a power cable AND/OR the USB drivers are not correct. Consult your phone manufacture website for the proper drivers are Windows will normally install universal drivers that will not work properly with the Google Android tools – SushiHangover Apr 18 '16 at 10:36
  • 1
    @mrbengi I see you removed the reference to the Sony phone, but I saw this SO answer that might help you finish the setting http://stackoverflow.com/a/16680934/4984832 – SushiHangover Apr 18 '16 at 11:36
  • Yes I'm currently trying for Samsung Note Pro and Samsung Note 2 so I wanted to change for Android, as general. – Bengi Besçeli Apr 18 '16 at 12:53