4

I'm working on some native c code for Android and trying to output using this code:

__android_log_write(ANDROID_LOG_INFO, "Native", "TEST LOG");

logcat within Eclipse and from the command line both fail to show the message, while showing output from calls to Log.d() from the java layer. I've verified with objdump that __android_log_write() is in the symbol table of my .so file.

Mark Murphy
  • 1,580
  • 1
  • 16
  • 29

1 Answers1

3

It should be

__android_log_print(ANDROID_LOG_INFO, "Native", "TEST LOG");

_print instead of _write

Don't forget to include <android/log.h>

Givi
  • 3,283
  • 4
  • 20
  • 23
  • 3
    __android_log_print and __android_log_write both exist. One takes a format string, the other doesn't. – James Moore Mar 19 '18 at 19:02
  • The answer is obviously wrong, I don't understand why it is marked as "answer"; __android_log_write is legit (see documentation). Android logging is buggy, well, Android is not iPhone, it has a lot of bugs that Google never fixes, if bug doesn't result in huge financial loss, it is not profitable for Google to fix it. Use any custom logging, it is more reliable. – Vitalii Jul 29 '19 at 10:33