How do I debug on a real Android device using Xamarin for Visual Studio?
Asked Answered
A

11

103

I've found a few links but they don't explain how this is done. I can debug using Xamarin Studio IDE but that IDE (no offense) is lame compared to Visual Studio 2012.
Using Visual Studio 2012, there appears to only be option to select an emulator to debug. So how do I get it to debug on my real device via USB (I already have USB Debugging = true)?

Ader answered 7/8, 2014 at 21:29 Comment(7)
You have installed the USB driver @ the Android SDK? Your device should appear in the 'Target Android Device'-dropdown as soon as you plug-in your device.Spinet
I can confirm this, with a correct setup you should see your smartphone as a deployment option the moment you plug it in.Mancini
if 'adb devices' shows your device it should be in VS. Try to restart VS after connecting your devices.Tournedos
Im sorry guys but I have installed the usb driver but still, the only option in the drop down in visual studio is for the emulator. If I use Xamarim Studio the phone is recognized though.Ader
Sometimes I have to open xamarin studio, select manage devices from the select device drop down and press refresh before my usb connected device will show in the visual studio list of devices. Also just a thought but the device needs usb debugging option set in developer options.Balkin
When connecting the device there's a message to select the way you wanna connect the device multimedia and PTP you should select PTP otherwise the device will not show in visual studioKilburn
@CrazyAlien That solve it for me MTP wasnt allowing to connectFarm
G
159

I'm using Visual Studio 2017 with a OnePlus.

In order get debugging working I did the following.

  1. Go to Settings > About phone and tap Build Number repeatedly until developer mode is enabled
  2. Go into Settings > Developer options and turn USB debugging ON
  3. Connect you phone to your PC via USB. I had to plug my phone into my PC's onboard USB port, not my USB hub as this did not work
  4. You should be prompted to trust your PC (trust it)
  5. Fire up Visual Studio
  6. Open your solution and your device should now be available.

Side note: I have noticed that sometimes it also depends on the cable you use. If you still have no luck, perhaps try another cable.

Goraud answered 2/8, 2016 at 11:33 Comment(6)
Thanks, this helped. My Lenovo Tab 3 only shows up in Visual Studio 2015 when I connect it by USB directly to the computer. If I try through a hub it doesn't allow USB debugging.Inchoation
Yes you are spot on, VS must be closed and make sure the phone is signed in to accept the prompt (item4). tksVallo
If you left your phone connected and visual studio open during this process, make sure to close VS then unplug and plug again the USB.Principium
I did all of this and my mobile device still doesn't show up in my debugger list despite showing in the Android Device Monitor. However, when I run Debug, my phone will still be used as the default device. I encourage everyone to press F5 before troubleshooting.Beirut
THANK YOU VERY MUCH. I hadn't debugged my Xamarin project for over a year and forgot how to do it. Following your steps made it easy!!!!!!Haymo
Worked perfectly with VS 2022.Assure
C
15

You will get a confirmation prompt on the android device to ask if the PC is allowed to connect. It's easy to miss this if your device's screen has gone to sleep.

Cinquain answered 22/1, 2015 at 18:41 Comment(1)
I should try plug in and out multiple times to get that notification. Don't know why. But it helps in my case.Bluecollar
S
12

I'm using Visual Studio 2015 with Xamarin and the only way I can get it to recognize my Galaxy S4 is to turn USB debugging off and back on again while VS is running. This is required everytime I wish to use this phone with VS. I've never had to do this with Android Studio.

Surrounding answered 20/4, 2016 at 10:27 Comment(3)
As Greg M. mentioned: You will get a confirmation prompt on the android device to ask if the PC is allowed to connect always. I confirmed this and my device is always recognized.Trews
Same solution works for me with VS 2015, LG Nexus 4 and Windows 7.Computerize
YOU ARE AWESOME GUYS !! It works for me after i install my Sony Xperia Z driver on my machine developer.sonymobile.com/downloads/drivers . I would like to note that the prompt will not show on your device unless you install the driver.Linker
C
8

1 - Original drivers (Example: http://androidmtk.com/download-samsung-usb-drivers)

2 - Enable Developer's Options on mobile (for example on android 4.2.2, perform 7 click on "mobile info" - "serial number")

3 - USB debugging on your Mobile Developer's Options too

Craigie answered 5/11, 2015 at 8:32 Comment(1)
Original drivers was the final solution.Embryologist
D
4

I also experienced a similar issue, I solved it by installing the USB drivers specific to my phone model.

Diocletian answered 9/3, 2017 at 9:9 Comment(1)
In my case (Samsung Galaxy S6), drivers were inapplicable (couldn't be installed) and everything works without them.Prelacy
H
2

tl;dr Install drivers if you haven't already done so.

As mentioned in one of the comments above I installed the device specific USB driver (LG drivers are here) and it solved my problem. It now works perfectly.

I was under the (incorrect!) impression I wouldn't need to install the drivers to enable debugging. I could already connect my device to my laptop to view files etc. and hence thought drivers were unnecessary.

Herod answered 20/10, 2015 at 21:36 Comment(1)
I randomly got prompted on an LG tablet after 20 minutes of struggling with this and it said "Install drivers on PC?" I said sure and it finally worked.Alectryomancy
A
1

Once everything else is ready, the device could appear under the "Not compatible devices" list. This could be happening if the "Minimun Android version" set in your project is higher than android version you have in your device. If so, you can set the "Minimun Android version" in the android manifest

Asti answered 29/11, 2017 at 2:4 Comment(0)
P
0

I set my Mobile connection in USB charging mode and enable USB debugging. It may ask for driver installation, after driver installation disconnect the mobile and reconnect it, now this should show in Visual studio device list for debugging.

Perhaps answered 6/4, 2017 at 6:8 Comment(0)
D
0

To enable debugging from Visual Studio for Mac 17 to a 2023 Samsung Galaxy A14 I needed to disable Fast Assembly Deployment in the Android project Build settings and switch the device USB from debugging to Transferring files / Android Auto.

Decant answered 26/5, 2023 at 22:31 Comment(0)
P
0

To do enable debugging on an OPPO with ColorOS, go to 'About device', scroll down to 'Version', tap on it and then tap a number of times on the 'Version No.' until it says 'Now you are a developer!'.

Then go to 'Developer Options', and enable them, if not already. Scroll down to 'USB debugging' and switch it on. Also switch 'Wireless debugging' on if you want to go that way.

Now the phone is listed among the devices in Visual Studio 2022 (v17.6.8) for Mac.

Parenteau answered 30/1 at 16:2 Comment(0)
S
-2

It looks like Xamarin Android Player is not installed. You will need to install this.

Segmentation answered 10/1, 2018 at 19:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.