When debugging in Unity Editor I can see the Debug.Log() output in the Console, which is great. However, when connecting MonoDevelop to a device I don't know where to find this output. It is not in the "Application Output" window. Breakpoints, variables, stack - all works fine. Is there a way to see the debug output in MonoDevelop?
Is there anything better then this answer suggests? Debug/Trace output in MonoDevelop
Use Debug. Log to print informational messages that help you debug your application. For example, you could print a message containing a GameObject.name and information about the object's current state.
Enable script debugging in a Unity player In Unity, open the Build Settings by selecting File > Build Settings. In the Build Settings window, mark the Development Build and Script Debugging checkboxes.
To debug a Unity application on a local computer Make sure the project you want to debug is opened in the Unity editor. In JetBrains Rider, open the corresponding Unity project solution. Set breakpoints by clicking the gutter next to a required line of code. Select the Attach to Unity Editor & Play run configuration.
1) Enable "USB debugging" on your device and connect the device to your development machine via USB cable. Ensure your device is on the same subnet mask and gateway as your development machine. Also, make sure there are no other active network connections on the device (i.e. disable data access over mobile/cellular network).
2) On your development machine, open up your terminal/cmd and navigate to the location of the ADB. You can find the ADB tool in /platform-tools/
3) Restart host ADB in TCP/IP mode with the following command: adb tcpip 5555
This should produce the following output: restarting in TCP mode port: 5555
This will have enabled ADB over TCP/IP using port 5555. If port 5555 is unavailable, you should use a different port. (See http://developer.android.com/tools/help/adb.html)
4) Find out the IP address of your Android device (Settings -> About -> Status) and input the following command: adb connect DEVICEIPADDRESS (DEVICEIPADDRESS is the actual IP address of your Android device)
This should produce the following output: connected to DEVICEIPADDRESS:5555
5) Ensure that your device is recognised by inputting the following command: adb devices
This should produce the following output: List of devices attached DEVICEIPADDRESS:5555 device
6) Build and run your Unity application to the device. Ensure you build your application with Development Build flag enabled and Script Debugging turned on.
7) The device no longer needs to be connected to your development machine via USB.
8) Finally, while the application is running on your device, open your script in MonoDevelop, add a breakpoint, select "Run" -> "Attach to Process" and select your device from the list. (Note that it might take a few seconds for the device to appear in the list. It may not appear in the list if the application is not running or if the device's display goes to sleep).
For some more details and for troubleshooting, see the Wireless Usage section in the Android developers guide for the ADB: http://developer.android.com/tools/help/adb.html#wireless
NB: The device sends multicast messages and the editor and MonoDevelop subscribe/listen for them. For this to work, your network will need to be setup correctly for Multicasting.
Taken From here
There are other ways also to debug your application in terminal
******************* On MacOS ***************************
Start Terminal from launchpad
First Method
Turn USB Debugging on, on your android device
Connect the android device through usb cable
Go to “platform-tools” folder in Adroid sdk folder by using “cd” command
Connect the android device through usb cable
type “adb devices” in terminal it will print the list of devices attached
type “adb logcat -s Unity ActivityManager PackageManager dalvikvm DEBUG” to see logcat of only unity related stuffs
Second Method
creating an environment variable to access ADB directly
Go to your home directory by typing “cd ~”
Type touch .profile this will create a hidden file named profile
Type open -e .profile this will open the file you just created in TextEdit
In the file, type export PATH=${PATH}:/AndroidSdkPath/android-sdk-mac_86/platform-tools
Save file, close TextEdit, Quit Terminal, and Relaunch Terminal
Turn USB Debugging on, on your android device
Connect the android device through usb cable
type “adb devices” in terminal it will print the list of devices attached
type “adb logcat -s Unity ActivityManager PackageManager dalvikvm DEBUG” to see logcat of only unity related stuffs
Now you can start your app/game on the target device and Terminal will log all the activities of your app.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With