Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

where is Android NDK printf output?

I have following code c++ code:

static void print_string(JNIEnv * env, jclass clazz, jstring str){
    jboolean isCopy;
    const char* utf_string;
    utf_string = env->GetStringUTFChars(str, &isCopy);

    env->ReleaseStringUTFChars(str, utf_string);
    //LOGI("%s",utf_string);
  //  LOGE("JNI Out = %s", utf_string);
    printf("jni out: %s",utf_string);
   __android_log_print(ANDROID_LOG_INFO, "MyTag", "The value is %s", utf_string);
    env->ReleaseStringUTFChars(str, utf_string);
}

I don't see any output in logcat. So where does it goes? How can I see it?

like image 655
masiboo Avatar asked Sep 27 '22 18:09

masiboo


1 Answers

Accordint to the docs the output is lost:

By default, the Android system sends stdout and stderr (System.out and System.err) output to /dev/null.

There are methods to change that (on rooted devices), for example using setprop, taken from the docs:

$ adb shell stop
$ adb shell setprop log.redirect-stdio true
$ adb shell start
like image 51
aghidini Avatar answered Oct 07 '22 09:10

aghidini