masiboo
masiboo

Reputation: 4719

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?

Upvotes: 5

Views: 2392

Answers (1)

aghidini
aghidini

Reputation: 3010

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

Upvotes: 4

Related Questions