Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [Android] Monitoring app on Android tablet from PC  (Read 2550 times)

0 Members and 1 Guest are viewing this topic.

korczurekk

  • Full Member
  • ***
  • Posts: 150
    • View Profile
    • Email
[Android] Monitoring app on Android tablet from PC
« on: September 27, 2016, 04:04:50 pm »
Hi!
I'm writting an app using SFML and am not sure how to get stdout/stderr/stdin on Linux PC while running app on tablet. I suppose it can be done using adb, but my research wasn't enough to discover how.  :(

I use this script to run project:
#!/bin/bash
pkg=$(aapt dump badging $1|awk -F" " '/package/ {print $2}'|awk -F"'" '/name=/ {print $2}')
act=$(aapt dump badging $1|awk -F" " '/launchable-activity/ {print $2}'|awk -F"'" '/name=/ {print $2}')
adb shell am start -W -n $pkg/$act
 
./run.sh bin/NativeActivity-debug.apk

dabbertorres

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • website/blog
Re: [Android] Monitoring app on Android tablet from PC
« Reply #1 on: September 27, 2016, 06:41:54 pm »
If your device is rooted, you can do this:
Code: [Select]
adb root
adb shell stop
adb shell setprop log.redirect-stdio true
adb shell start

Otherwise, the next best thing is manual logging:

Include the logging header file:
#include <android/log.h>

Use the built in logging functionality:
__android_log_print(ANDROID_LOG_INFO, "foo", "Error: %s", foobar);

By default, Android redirects stdout and stderr to /dev/null (Although Java's System.out and System.err get re-redirected to Android's logging system).
« Last Edit: September 27, 2016, 06:43:28 pm by dabbertorres »

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: [Android] Monitoring app on Android tablet from PC
« Reply #2 on: September 27, 2016, 09:56:24 pm »
You're looking for "logcat", which is essentially event logging where SFML prints its messages as well (rather than std::err).

Display logcat in realtime/continuously:

Code: [Select]
adb logcat
Clear logcat:

Code: [Select]
adb logcat -c
Show logcat till now (e.g. useful to show everything from the last few seconds):

Code: [Select]
adb logcat -d

dabbertorres

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • website/blog
Re: [Android] Monitoring app on Android tablet from PC
« Reply #3 on: September 27, 2016, 11:43:23 pm »
Is SFML's Android port using logcat internally? I found normal stdout and stderr didn't even show up there without doing what I mentioned above.