1

During running a test in the debug mode I see no way to see my println output. It is not an Android Test so it is not running in emulator and/or on the device.

I am using Android Studio 3.5.2.

How can I see what was displayed by println commands? I tried:

  • Logcat (not working as expected, as I am not running tests in emulator or on the device)
  • Debug tab, and checked both Debugger and Console subtabs
  • Terminal tab - show new terminal without program output
  • Build - as expected, nothing relevant

I also tried:

  • restarting Android Studio
  • restarting system
  • restarting Android Studio with clearing caches
  • looking for an alternative IDE, it seems that Android Studio has a de facto monopoly (Eclipse is the only potential alternative, but for now I am stuck with Eclipse crashing at startup and discovery that my OS version is EOL, so now I am going to upgrade from Lubuntu 16.04 )

To avoid XY problem: I want to see my println output as I run into a bug in a debugger and state of my variables is hidden - see "Variables are not available" appearing sometimes during debugging, on stepping through program (Android Studio 3.5+)

reducing activity
  • 1,985
  • 2
  • 36
  • 64
  • 2
    Is there any particular reason you use `println` instead of `log.d`? – gkpln3 Dec 11 '19 at 14:20
  • @gkpln3 Tests are not running on the Android device or emulator, I thought that `Log.d` and its friends will not work. I just tried and it is not appearing in any place that I see. – reducing activity Dec 11 '19 at 14:25
  • 1
    Take a look at this question: https://stackoverflow.com/questions/37190243/why-log-d-print-nothing-when-running-android-local-unit-test – gkpln3 Dec 11 '19 at 14:26
  • @gkpln3 It is not appearing in the log tab (neither `println` nor `log.d`) and Android Studio has now no "Android Monitor" tab (it seems that it is now called "Logcat"). I can attach a screenshot. Thanks for trying to help! – reducing activity Dec 11 '19 at 14:30
  • 2
    It should appear on Debug->Console. – greeble31 Dec 11 '19 at 15:22
  • Thanks! I now added `System.out.println("aaaa")` test call directly within test function (not within called code). Now I need to figure out what the heck is happening that captures messages. – reducing activity Dec 11 '19 at 16:04
  • In regular tests, logging should be handled by slf4j via a Logger object – OneCricketeer Dec 14 '19 at 11:26
  • @cricket_007 From what I see slf4j is just a wrapper, so it should not influence whatever console output is visible, right? – reducing activity Dec 14 '19 at 11:34
  • No but you can filter between info, debug, warn, error, etc... Just like Logcat – OneCricketeer Dec 14 '19 at 11:34
  • Not OP, but I can speak for myself: I'm debugging someone else's code and it's full of calls to `System.out.println()`. I *do* see the output in the "Run" tab if I run the unit test, but there's no output when debugging. – Edward Falk Feb 22 '23 at 21:38

0 Answers0