Tuesday, 15 July 2014

Android 5 - Redirect stdout to logcat -



Android 5 - Redirect stdout to logcat -

i trying run gmock/gtest tests on android. these run fine, there's no output, gmock logs stdout.

i've tried next no luck (likely because it's dalvik vm, , they've done away in android 5):

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

when log.redirect-stdio set true, there still no output stdio logcat.

i've tried custom several streambuf implementations std::cout.rdbuf seek direct stdout logcat __android_log_print, none of these have printed logcat.

has managed redirect stdout logcat in android 5?

i can add together more details (such streambuf implementations i've tried) if needed.

this isn't solution problem of redirecting stdout logcat, i'm suggesting workaround in case helps someone.

you can redirect stdout file instead:

freopen("/data/data/com.your.package/files/out.txt", "w", stdout); ... // phone call gmock prints file instead fclose(stdout)

we can cat file see logged test results. sadly android doesn't have tail logging isn't nicely available in real time. (unless you're @ spamming cat)

android stdout logcat googletest android-5.0-lollipop

No comments:

Post a Comment