Debug Android device in Unity (via USB)

I only started working with Unity yesterday and since I come from Eclipse, where you can simply connect your phone to your PC via USB (with developer mode and USB debugging enabled, of course) and it instantly starts showing logs in Logcat (it doesn’t even matter if you start the app directly on your phone or through Eclipse), I’m a bit confused about how you’re supposed to debug your app in Unity.

If I press the “Play” button, it shows my “Debug.Log(“test”);” log but how do I get the logs while the app is running on my actual Android device?

I already tried “Run - Attach to Process - ‘Unity editor’ - Attach” in MonoDevelop and “Debug - Attach Unity Debugger - pick my app - Okay” in Visual Studio but it doesn’t show any logs in any of the tabs that open up.

The console in Unity has an option to switch from “Editor” to “AndroidPlayer(ADB@127.0.0.1:34999)” but it doesn’t show my logs then either.

I can’t use wifi and I don’t want to debug using cmd because it’s a pain in the butt to start up and find anything.

Versions:

  • Unity: 2017.3.1f1 Personal
  • Win 10
  • Android 7.0

hey ;
u can use logcat for unity too;

// run this in commend promphet when the mobile is attached and the game is runing;

adb logcat -s Unity ActivityManager PackageManager dalvikvm DEBUG

I found a good workaround:

The Android SDK has its own stand-alone monitor (that looks like the logcat in Eclipse/Android Studio)!

Path: tools\lib\monitor-x86\monitor.exe

or: tools\lib\monitor-x86_64\monitor.exe

or just use the .bat file: tools\monitor.bat

You don’t have to attach Unity’s debugger to it, simply connect your phone to your PC via USB cable (make sure it’s in developer mode), open up the monitor and it should pretty much instantly start giving you log messages.

To only show Unity’s logs, add a new filter that uses the log tag “Unity”.