Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
5
Question by Mangiarotti · Mar 04, 2017 at 09:04 AM · androiddebug

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

http://answers.unity3d.com/questions/175161/debugging-android.html // Someone suggests to do it in Eclipse, ridiculous, also I don't think it would work.

http://answers.unity3d.com/questions/976860/how-to-debug-an-android-application-in-visual-stud.html // 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

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image hexagonius · Mar 04, 2017 at 10:42 AM 0
Share

you said an obvious reason for not profiling over WiFi would be the deployment time. But deployment is easily done using USB. It's just the "reading" that goes over WiFi and only for the profiler. logcat is also read over USB.
What exactly is it that you're missing?

avatar image Mangiarotti · Mar 04, 2017 at 11:49 AM 0
Share

$$anonymous$$y point is NOT to question about how good the WiFi debug works or how to get it work correctly after deploying trought USB, I'm asking how to do a USB debug, it seems a reasonable question to me and I don't think i'm asking for the moon or something. I said obvious reasons because thinking about the possible issues related to debugging trough WiFi they seem pretty obvious to me, I apologize for that, here's a few motivations that could make the WiFi debug unsuitable: I need to debug a method that is executed on Awake of my first scene without implementing workarounds. $$anonymous$$y company has 100+ people connected to the same WiFi working on unity and we all cannot afford to fill the network by continuously debugging trought wifi. $$anonymous$$y company does not use WiFi connection, we all are connected trought LAN. $$anonymous$$y company has a very strict policy on network security, tough all non standard ports are closed and we cannot afford to open them. Once again, I'm not asking how to make the WiFi debug work in my particular situation, I can already do that, I'm asking how to debug Android device trough USB supposing there's no WiFi network at all.

7 Replies

· Add your reply
  • Sort: 
avatar image
7
Best Answer

Answer by kostasandre · Mar 05, 2017 at 04:08 PM

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

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Mangiarotti · Mar 29, 2017 at 12:04 PM 0
Share

This is indeed the correct answer! Thanks a lot! Still this is not specified anywhere in the documentation, also the debugger connection seem to be somehow unreliable: sometimes the "select unity instance" window correctly displays the connected device while sometimes it does not, that's what led me into asking how to do it here: even though I guessed that was the way to it I wasn't able to see my device in the "select unity instance" window in any way, and thus I tought I was doing something wrong. Trying to do it several times randomly made it work. I freshly installed both Unity 5.5.2 and Visual Studio 2015 on a brand new machine so I doubt there are issues related to an unclean Unity/VS installation

avatar image irreverent · May 29, 2017 at 10:27 AM 0
Share

I'm hitting the same problem than $$anonymous$$angiarotti. I cannot see my Android device, currently running the game, in VS-Debug-Attach to Unity debugger. In your instructions, how did you "launch your app"? Did you use "Build&Run" from Unity?

avatar image unity_aqncsY39wsGZ1g · Feb 12, 2020 at 08:36 AM 0
Share

This did indeed debug the app running on the device, but it did through wifi, at least for me. Am I missing something? Turning wifi off in the device will not list it in the Attach unity debugger menu.

avatar image Ali17X · Aug 23, 2020 at 09:31 AM 0
Share

thanks alot!

avatar image
7

Answer by ow3n · Aug 11, 2017 at 05:57 PM

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

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
5

Answer by FlyVC · Jul 13, 2020 at 11:31 AM

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.

alt text


sdkroot.png (32.7 kB)
Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image GastonHilkhuysen · Jan 22, 2021 at 10:35 AM 0
Share

This worked for me. Thanks, your post saved me a day of work... or even more.

avatar image jiyongman · Apr 16, 2021 at 03:04 AM 0
Share

This! I had been frustrated for years and almost gave up on debugging via USB, and someone finally gave me a real solution! In fact, I failed at first and immediately thought this wasn't the answer either, but after trying some more times, it worked. Try again after killing the current adb process. Restarting Visual Studio and your Android app may help too.

Thank you bro!

avatar image PadraigCrowleyGames · Feb 17 at 03:47 PM 0
Share

Yesss! After hunting high & low, this was the missing part of the puzzle for me!

avatar image
4

Answer by seaophiel · Jul 29, 2017 at 01:56 AM

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


f-02.jpg (80.1 kB)
f-03.jpg (22.1 kB)
Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image spsarras · Jan 09, 2019 at 07:57 AM 0
Share

For the first image on VS:

Debug>Attach Unity Debugger Select your device on the next window, while your app running. There is a check-mark on the Build Settings of Unity that you can allow for a delay before your app starts to setup your debugger. It is called: "Wait for managed debugger"

Thanks mate!

avatar image
1

Answer by sora_jp · Mar 05, 2017 at 03:37 PM

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

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Mangiarotti · Mar 05, 2017 at 03:52 PM 0
Share

Thanks but using -s flag just filters the logcat output by tag name, What I need is to debug, to be more clear I need my program to block its execution when a previously placed breakpoint is reached, allowing me to evaluate variables, procede in execution step by step etc.. Debug stuff, you know?

  • 1
  • 2
  • ›

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

16 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Scene white after building 1 Answer

App crashes when trying to debug on Android 0 Answers

Certain gameobjects not in mobile build 1 Answer

[Closed] What is "Filename: ./Runtime/ExportGenerated/AndroidManaged/UnityEngineDebug.cpp line: 54" 0 Answers

Not getting where error comes from which line when debugging on Android 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges