-3

I'm running a Unity3D app and have put some prints (Debug.Log and print) around the code which should be getting hit. I've confirmed that they are and have made sure all logging in build settings are set to 'Full'.

Not sure why the output isn't coming through in adb logcat. However interestingly null reference exceptions are being printed so there must be something going on there..

For example I have the following code in ana update function in a scene (and nothing else):

void Update(){
    print("WILL THIS WORK?");
    Debug.Log("####################### I AM HERE");

    object o = null;
    print(o.GetType());
}

adb logcat shows the following output:

enter image description here

I just found the only type of logging which works is Debug.Error, so this might have to do with some level of error logging but not sure what it could be, in my inspector I have the following set:

enter image description here

So it should log everything..

meds
  • 21,699
  • 37
  • 163
  • 314
  • How and where are you trying to view the logs? Can you put a screenshot to also show this? – Programmer Feb 05 '18 at 11:06
  • just running adb logcat in powershell, there isn't much of a screenshot to show in that regard hehe. – meds Feb 05 '18 at 11:09
  • Use Android Studio with built-in Android Monitor instead. This is possibly a duplicate of [this](https://stackoverflow.com/questions/44690357/how-to-read-debug-log-when-using-android/44690501#44690501) – Programmer Feb 05 '18 at 11:14
  • Android Studio is also using adb logcat so no love threre sadly – meds Feb 05 '18 at 11:18
  • Did you try closing Unity and only running the logcat in powershell? Also try Uninstalling the app from the Android device, and installing a clean version. – Hristo Feb 06 '18 at 13:05

1 Answers1

0

Pay attention to your screenshot. You cannot see your own log because Unity is showing its own error. Usually, when you get an error the rest of the code in that frame is abandoned until the next frame. This used to be the behavior of Unity and I think it's still the behavior and your current issue. That error in your Update function in the Platform.TestAuth script.

Fix the NullReferenceException you are getting and then you should be able to see your log appear.

Programmer
  • 121,791
  • 22
  • 236
  • 328
  • Sorry I should have clarified that I did try running it without the null reference exception, it was there simply to prove that there is some logging from the app. If you look at the code I posted: object o = null; print(o.GetType()); it's quite obvious what I'm trying to do hehe :) – meds Feb 05 '18 at 11:42
  • I should also add that while I'm not 100% sure how Unity treats errors in Android with logging, in the editor it most certainly outputs "WILL THIS WORK/#### I AM HERE" followed by the null reference exception.. You are right in that Unity will abandon the rest of the code under the exception but not above it, I suspect that code has already executed by that point. – meds Feb 05 '18 at 11:44
  • Then remove that part that is causing that error. Just remove it and put a simple `Debug.Log` message. Post a new screenshot of what getting. Finally, try the Android Studio I talked about and also report back on the outcome. – Programmer Feb 05 '18 at 11:46
  • As I already said nothing comes up in debug.log so there's nothing to show besides an empty log if I'm not inducing an exception, the logging in the screenshot is actually pulled out of Android Studio and the dupe question answer did not help. I've updated my question as I made a new discovery. – meds Feb 05 '18 at 11:52