Hi Zulu here… (First of all … sorry for the cat)
Let me say straight off that your first port of call for any Unity debugging should be the Unity Console.
Though sometimes you need more low level operating system logging for Android. This is where ADB (in lower case) comes in.
On Windows this is a command line tool to view the logs from a connected Android device.
The command line is not the only way to use the tool sometimes it’s better to use the Android Studio interface (a bit more graphical).
You will need to have your Android device connected to your workstation and USB debugging turned on (Google that if you need to). You could also use an Android emulator on your desktop.
I use Leapdroid or KoPlayer. (Leapdroid have now joined Google and no longer support the emulator but it’s still available to download on the internet). I guess you could also use the emulator that comes with Android Studio.
When your game is installed and running on your device go to the directory in your workstation (PC) where the Android SDK Tools are.
On mine they are here:
C:\Users\<user_name>\AppData\Local\Android\sdk\platform-tools
In the tools directory open the monitor.exe (this tool was depreciated in Android Studio 3.0 and replaced with profiler.exe mine is still on the lower revision).
This documentation on the Android site is a good start investigating the profiler:
https://developer.android.com/studio/profile/android-profiler
You can also get into LogCat directly from Android Studio (if you have it open):
Go to View | Tool Windows | Android Monitor
At the bottom of Android Monitor in it’s own tab is the LogCat console window. This contains all of the information about what’s happening in the Android operating system.
As you can see the LogCat console contains a lot. It logs everything.
To filter it type “tag:Unity” in the textbox at the top to see messages that relate to Unity.
Using adb logcat from the command line
Open a command prompt on your development workstation and find the location of your Android SDK platform-tools folder.
Mine was here:
/Users/YourUserName/Library/Android/sdk/platform-tools
If you get this error when you run adb.exe using the command prompt:
‘adb’ is not recognized as an internal or external command operable program or batch file
You can add ‘adb’ to the $PATH environment variable (and restart the command prompt).
setx PATH "%PATH%;C:\Users\AppData\Local\Android\sdk\platform-tools"
To run logcat through the adb shell, the general usage is:
[adb] logcat [<option>] … [<filter-spec>] ..
This is the official Android Developer Logcat Command-Line Tool documentation:
https://developer.android.com/studio/command-line/logcat
but you can get –help on the command line.
It can be handy to know the device id of your Android phone/tablet whatever. This command will help:
C:\Users\<user_name>>C:\Users\<user_name>\AppData\Local\Android\sdk\platform-tools\adb.exe devices
List of devices attached
ce10171a5c19853003 device
You can specify that the log spew into a file instead of into your console (the console is pretty much useless as there is too much to scroll through).
C:\Users\<user_name>\AppData\Local\Android\sdk\platform-tools\adb.exe -d logcat > adb_logcat_out.txt
-d use USB device (error if multiple devices connected)
logcat show device log (logcat --help for more)
-s SERIAL use device with given serial (overrides $ANDROID_SERIAL)
The default Log Location on my machine was:
C:\Users\<user_name>\AppData\Local\Temp\adb.log
A few seconds of output got me a 6.5 MB file so a bit of filtering is advisable
If you run into trouble with the adb server just kill it and restart.
C:\Users\<user_name>\AppData\Local\Android\sdk\platform-tools\adb.exe kill-server
C:\Users\<user_name>\AppData\Local\Android\sdk\platform-tools\adb.exe logcat -s ce10171a5c19853003 DEBUG
C:\Users\<user_name>>C:\Users\<user_name>\AppData\Local\Android\sdk\platform-tools\adb.exe logcat -s ce10171a5c19853003 DEBUG
* daemon not running; starting now at tcp:5037
* daemon started successfully
--------- beginning of main
--------- beginning of system
If you want further help check out these pages from the Unity Manual and Tutorials:
https://docs.unity3d.com/Manual/TroubleShootingAndroid.html
https://docs.unity3d.com/Manual/LogFiles.html
As a final word I’ll also direct you to this package called Device Console on the Unity Asset Store. I’ve not used it but it looks really good and for fifteen dollars might save you a lot of hassle.
https://assetstore.unity.com/packages/tools/utilities/device-console-44935