When using JNI in a Java environment, you can easily print information using the printf function, and in the Eclipse Console console view it is easy to observe that if you use JNI in an Android environment, the printf function will not work. No output is visible in the Logcat view and the console view. But we can use the log method of Android itself to implement the following steps:
1, in the JNI implementation code file (. C or. cpp), add the following code containing the log header file:
#include <android/log.h>
2, in the need to print the method to add printing code, such as:
__android_log_print (Android_log_info, "Jnix431filetest", "Lsx_init");
Android_log_info: is the log level;
"Jnix431filetest": the label to filter, which can be filtered in the Logcat view.
"Lsx_init": is the actual log content.
3. Add the following content to the Android.mk file in the Android project:
Local_ldlibs + =-l$ (sysroot)/usr/lib-llog
4, OK, now you can print the information.
As for how to implement an Android project called JNI Local/C + + functions can refer to the previous blog:
http://blog.csdn.net/jjunjoe/article/details/7007052