Why does redirecting stdout / stderr on android not work?

I downloaded SDL 1.3 and tested it with OpenGL ES on my Android 2.2 device. It works fine, but I am not getting exits from printf calls. I tried the commands below, as mentioned on the Android developers page , but neither DDMS in Eclipse nor adb logcat reports the lines that the program writes using printf . I made a filter for the stdout tag.

 $ adb shell stop $ adb shell setprop log.redirect-stdio true $ adb shell start 

What am I missing or is something wrong?

+10
android stdout android-ndk native
Mar 31 '11 at 11:38
source share
2 answers

Another way to do this is to have a /data/local.prop file containing only the line log.redirect-stdio=true . Maybe this works better? Also, note that stdout is buffered, so it may be that your output is still sitting in the buffer, waiting for it to turn red. You can invoke fflush manually to verify this.

+1
Apr 01 2018-11-11T00:
source share

According to this presentation, log.redirect-stdio for Dalvik output, to redirect C / C ++ output (e.g. printf ), you should install busybox on the device and use its xargs utility as follows:

 myprogram | xargs log 

This obviously works for code that is called as a standalone executable. If this is for debugging purposes only, you can write a small program to call your library and call it from your application using xargs .

+2
May 14 '12 at 10:16
source share



All Articles