Android Debug USB

Hello, I’m trying to debug my Unity application on an Android device,
I would like to debug it trough +++USB+++ connection, because the WiFi debug is sure a fancy feature, but it is not suitable for actual working for obvious reasons (too much time to deploy in first place)

I don’t mind doing it in MonoDeveloper or Visual Studio, at this point I wouldn’t mind even doing it on windows notepad (JK, of course I want to do it in Visual Studio, but if there’s no alternative MonoDeveloper would be fine too…).

I already wasted a lot of time searching on the internet how to do it, looking into the official documentation as well as on answers/forums, but it seems no one actually proposes a working question.

Here’s some of the answers I found so far, non of them fits my senario:

https://docs.unity3d.com/Manual/AttachingMonoDevelopDebuggerToAnAndroidDevice.html?_ga=1.194662509.1315832825.1488531312
// Suggest to use WiFi debug

https://support.unity3d.com/hc/en-us/articles/205485376-How-do-you-debug-on-Android-?_ga=1.194662509.1315832825.1488531312
// No usefull answers

https://forum.unity3d.com/threads/any-tips-for-debugging-android.70197/
// Talks about unity 3.1

https://forum.unity3d.com/threads/attaching-monodevelop-debugger-to-an-android-device.245814/
// No usefull answers, most people refers to the WiFi usb solution

// Someone suggests to do it in Eclipse, ridiculous, also I don’t think it would work.

// Someone from ur team (I suppose) says that android debug currently works only via WiFi adding that " USB debugging is on our list with high priority", stated on 01/06/2015

Since I cannot believe that in 2017 there’s no clear explantion on how to do it on the platform considered the standard for game development I hope somehow my careful search has somehow missed the internet page where how to do that is clearly exaplained step by step.

Thanks

Hello i am able to debug on vs and on monodevelop via usb.
In VS go to Debug-> Attach unity debugger(Click on that first ,then launch ur app and you will see it in the menu click ok and ur done)
In MonoDevelop Run-> Attach to Process and do the same as above
Make sure you have adb on on your phone and all the sdk’s needed

Hope this helps

I tried everything that was suggested here and spent a whole day dealing with this S***

The final missing part was the empty “Preferred Android Sdk Root” path.

After copying the sdk path from Unity->preferences->external tools to
VisualStudio->Tools->Options->ToolsForUnity->Debugging->Preferred Android Sdk Root
the AndroidPlayer(USB) finally poped up in the Debug->SelectUnityInstance Menu and debugging finally works!

When the path is left blank, it should take the one that’s set in Unity, but this seems bugged.

I did all these things but eventually I realized (on my Samsung device) that I had to also enable debugging for the specific app as well. My steps for using ADB on the command line:

Android device go to Settings > Development

  1. Turn development ON
  2. Set USB debugging ON
  3. Select app to be debugged (choose your app after first build)

On Mac

  1. Install ADB: brew cask install
    android-platform-tools
  2. In Unity Build settings: Development
    checked, Script debug checked
  3. Build to Android

In Terminal

  1. List devices attached: adb devices
    -l
  2. Start debugging: adb logcat -s Unity
    DEBUG

After many hours finally today I was able to debug step by step from visual studio 2015, with my smartphone connected via USB

I did the following:

1.- Have the device connected to the computer via USB
2.- Have a keystore
3.- In Unity Editor “File-> Build Settings” have selected android, Development checked, and script debug checked
4.- Select “Build And Run”
5.- From Visual Studio “Debug-> associate unity debugger (or select unity instance)” this will not show even the UBS device
6.- I had to stop the game on my device and start it again

7.- After restarting the game an wait a little this appeared in the list of devices connected in visual studio

8 After this I could debug normally like any visual studio application

I hope it works for someone
Apologies for my basic english
regards

Download the android sdk and install the platform tools. Then navigate to the platform_tools folder in the sdk and run adb logcat -s Unity in a command prompt in the directory

How to debug an Android application in Visual Studio using USB debugging? - Questions & Answers - Unity Discussions

I made helper application, debug over usb

I am not sure if someone will face the same issue. If you need to debug android app, enabling “development build” is NOT ENOUGH! You need to to enable also “script debugging” and only in this case you will be able to see running app on a mobile within “attach to unity debugger” window of Visual Studio. Good luck!