Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 antique · Sep 06, 2015 at 12:39 PM · visual studiodebugdebugging visual

Debug android with visual studio tools for unity

I have successfully connected to my android phone via wifi and I'm able to deploy apps that way ( using the default adb port 5555). However when I try to debug my app from visual studio 2015 ( Debug -> Attach Unity Debugger) I just can't connect. The ip address I enter is 100% correct. I disabled my firewall and enabled development build & script debugging. So far I tried using ports: 59694, 5555, 56580 and 56000 - with no luck. Does anyone know what port unity uses for script debugging?

Comment
Add comment · Show 1
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 Suduckgames · Aug 24, 2017 at 10:06 AM 0
Share

Did you get your debug working? how do you did? I am having same problem

7 Replies

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

Answer by jules43 · Oct 07, 2015 at 08:21 AM

I had this exact problem and went back to MonoDevelop in frustration (Edit->Preferences->External Tools). However, after a couple of reboots and successfully debugging with MonoDevelop I thought I'd try again and this time it appears to be working fine.

When you use Debug->Attach Unity Debugger it should list a second process called AndroidPlayer on a machine called @ and a port. In my case the port was 56650.

You shouldn't need to explicitly provide an ip address.

If it still doesn't work, worth trying MonoDevelop which works in nearly identical way.

Note that to attach your Unity app has to be running on the phone, the phone has to be enabled for debugging and you need to have used adb to connect to your phone.

For this to work your phone needs to be enabled for debugging and you need to have connected to it using adb. Have a look at steps 1, 2 and 22 (the notes). https://www.reddit.com/r/GearVR/comments/2qcryc/step_by_step_guide_to_building_apps_for_the_gear/

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 jules_fpvr · Jun 14, 2017 at 08:22 AM 0
Share

$$anonymous$$isher's answer is also very helpful. You also need the firewall to allow devenv.exe through the firewall.

avatar image
5

Answer by misher · Mar 01, 2017 at 07:15 AM

You can use whatever port you want (ex: 5555). First of all, try to disable windows firewall, then in Visual Studio open "Debug"->"Attach Unity Debugger" and you should see "AndroidPlayer". If it is the case, turn on again firewall and add new inbound rule, select program Visual Studio exe file ("devenv.exe" in my case) and allow anything. This way you can debug having firewall enabled.

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 martinasenovdev · Oct 20, 2018 at 08:39 PM 0
Share

best answer. works like a charm!

avatar image
1

Answer by pgilmorepf · Jun 18, 2016 at 05:38 AM

I have discovered that my Unity is not opening the debugger on the default port. For Windows 10, I opened cmd and ran:

 netstat -an

In the results, look for a line like this:

 TCP    0.0.0.0:56956          0.0.0.0:0              LISTENING

It'll (probably) be in the 56XXX range. The default that VS tries to use is 56000, but mine was apparently 56956.

Use the Debug dropdown menu, Attach Unity Debugger, and change the port number to the port number you find in the netstat results.

My visual studio would not auto-detect this in the instances window, but if I manually input the port number, it just worked, and catches breakpoints and everything as expected.

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 MortePCAndVR · May 02, 2018 at 04:10 AM 0
Share

Be careful that you don't just pick any 56xxx port thinking it will be for your connected Android device.
In my case, the only 56xxx port listening was the Unity Editor, on port 56544: e.g. E:\dev\android-sdk\platform-tools>netstat -an

Active Connections

Proto Local Address Foreign Address State

TCP 0.0.0.0:56544 0.0.0.0:0 LISTENING

and in VS: (Debug->Attach Unity Debugger) alt text

Ins$$anonymous$$d, you should be able to see your Android device in the debugger if you try an adb tcpip & connect. e.g. running an AVD emulated device, (which uses localhost as the ip address)

E:\dev\android-sdk\platform-tools>adb devices

List of devices attached

emulator-5554 device

E:\dev\android-sdk\platform-tools>adb tcpip 5555

restarting in TCP mode port: 5555

E:\dev\android-sdk\platform-tools>adb connect localhost

connected to localhost:5555

E:\dev\android-sdk\platform-tools>adb devices

List of devices attached

localhost:5555 device

emulator-5554 device

On starting your Unity AP$$anonymous$$ in Android (built with Development Build+Enable Scripting), you should see an extra entry in the VS Debug->Attach Unity Debugger list: e.g. alt text

Even with Android running the Unity AP$$anonymous$$, netstat did not detect that port # as listening or otherwise: E:\dev\android-sdk\platform-tools>netstat -an | findstr "56014"

E:\dev\android-sdk\platform-tools>

Similarly, for an actual Android device:

E:\dev\android-sdk\platform-tools>adb devices

List of devices attached

03157df3d86de113 device

E:\dev\android-sdk\platform-tools>adb tcpip 5555

restarting in TCP mode port: 5555

E:\dev\android-sdk\platform-tools>adb connect 192.168.0.5

connected to 192.168.0.5:5555

E:\dev\android-sdk\platform-tools>adb devices

List of devices attached

192.168.0.5:5555 device

03157df3d86de113 device

Then run the built AP$$anonymous$$ in Android, and VS Debug->Attach Unity Debugger list shows: alt text

Annoyingly, at the moment, VS debug breakpoints & stepping are only working for me with a real device, not with the AVD emulated device...

Interestingly, while debugging on the real Android device, netstat -an shows an established connection:

TCP 192.168.0.38:10742 192.168.0.5:56453 ESTABLISHED

avatar image
0

Answer by goneale · Jun 27, 2016 at 01:48 PM

There is also a current issue with an incompatibility between having Xamarin installed and using VS Unity Tools. Microsoft is on to it, see post by Sebastien [MSFT] here: https://visualstudiogallery.msdn.microsoft.com/8d26236e-4a64-4d64-8486-7df95156aba9

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
0

Answer by playerone00 · Oct 10, 2016 at 09:21 PM

This doesn't work me. My VS tries to use port 56664 (I have option Attach to UNity:User-PC:56664). I have android device connected to host machine with IP 192.168.0.10. When I run Attach to Unity Debugger or Attach to UNity:User-PC:56664 nothing happens.

I thought that I had to have "Attach to UNity:androidphone:56664 " option in VS2015.

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 pgilmorepf · Oct 21, 2016 at 05:16 PM 0
Share

I agree, it doesn't always work. I've had spans of time where it works great, and spans of time where it won't work at all, and I haven't deter$$anonymous$$ed the independent factor.

avatar image pgilmorepf pgilmorepf · Feb 10, 2017 at 09:51 PM 0
Share

I have found that if I have too many ports open in other programs, then VS still can't connect, even if I give it the right port number. In my case, I usually run Jenkins and sometimes Apache on my local machine. I have found it quite reliable, that if it won't connect even with the correct port, then disable everything of this nature, including browsers, and then it will connect the debugger. Don't even have to restart visual studio.

There might be something in the unity vs tools plugin that only searches a fixed number of open ports, and gives up if there's too many.

avatar image ashokdamani pgilmorepf · Apr 14, 2018 at 08:01 PM 0
Share

@pgilmorepf Hi, Can you please exactly tell, what do you mean by disable everything of this nature including browser, What sort of things you meant and which browser?, are you talking about web browser?

Show more comments
  • 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

15 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

Related Questions

How do you Debug Unity Player Builds? 0 Answers

Problem debuging code using VisualStudio 2017 and Unity2019.1.0a10 1 Answer

How do you get OutputDebugString to show up in the Visual Studio output window? 0 Answers

Impossible to use Visual Studio 2015 Debugger anymore (Unity 5.2.1f) 2 Answers

Visual Studio 2015 debugger can no longer attach to Unity after installing RC3 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