Recently I needed to use Android Logcat for some debugging. But to my surprise, I couldn’t find a single Unity output. All other ADB Logcat outputs were there, yet unity was failing to show a single output.
For example I could see outputs with the tags “I/UnityAds” but there was nothing with “*/Unity” tag. I then proceeded to use Unity Android Logcat package instead of the Android Studio Logcat or the ADB Logcat from command line.
Yet even Unity didn’t see its own Debug.Log() outputs in the logcat, but it was showing up on the Unity console outputs. I made an empty project with a script that just screams “POTATO” at me with Debug.Log and I made it turn a cube GameObject on and off to see that the script was working.
Low and behold, it was working as intended! The console screamed “POTATO” at me, the cube was flickering on and off, yet the Logcat did not give me a single “POTATO” or any Unity tagged outputs.
Here’s the code:
using UnityEngine;
public class testDbg : MonoBehaviour
{
private bool flag = true;
public GameObject go;
void Update()
{
Debug.Log("POTATO"); // This should scream POTATO at Logcat
go.SetActive(!flag); //This just visualizes that the code is working
flag = !flag;
}
}
Am I going insane? Isn’t this supposed to be working?
Maybe it’s not even getting to Update(), can you place similar debug statements in Start() and Awake()? I use a command prompt as in the article I shared using “adb logcat” but they should also show in your output. Also, ensure you attach this script to a game object in your scene.
Well I see other messages with no filters as you can see and I also opened terminal to do the Command Line logcat and it works as well, its just unity thats not saying anything.
Then I guess Android Logcat window behaves as expected, as the same result is displayed by directly invoking adb logcat.
The question, is why messages are not coming through.
Did you try selecting Development check box in Build Settings window? Not sure if it will help, but a long shot, since if Development is unchecked, the application is “not debuggable”, maybe it affects logging.
Unfortunately it is checked. I am really mind boggled, I tried everything in the book, fresh installing Unity, fresh installing Android studio, outsourcing the adb and putting it in sdk, and the funny thing is everything EXCEPT unity is sending outputs, that’s why I am so irritated by it, hope in time a solution will emerge
Could you try creating a new empty project with simple script which calls Debug.Log or even Debug.LogError, and see if that changes anything.
Alternatively, could you try using another phone?
It works as expected for me. I did Build (vs Build and Run) and then “adb install mybuild.apk” to install on my Samsung Galaxy Edge S7 . Then I ran “adb logcat | findstr -i hello” (I’m on Windows, use grep on Mac) and saw my “Hello from Awake”, “Hello from Start”, and then a bunch of “Hello from Update”. I’m using 2020.1.13f1 but never saw an issue with Unity 2019 either.
Use print() instead of Debug.Log(). I have been doing this for years across many projects. This problem is not new to me so I wonder what the setup is for people that say Debug.Log() works. Also, everyone says print is identical to Debug.Log but for me it is not so again, are people making statements without even verifying or is there some setting I’m not aware of?