2010102114272010.10.21 How to use "logcat" in JNI

The four instructions for using "logcat" in JNI:

   1. Include the header file "android/log.h" as follows:

           #include <android/log.h>

   2. Define the need functions as follows:

       I only the one.

           #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG  , "liblog",__VA_ARGS__) 

      Other functions is below:

           #define LOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, "liblog",__VA_ARGS__)

           #define LOGI(...) __android_log_print(ANDROID_LOG_INFO, "liblog",__VA_ARGS__)

           #define LOGW(...) __android_log_print(ANDROID_LOG_WARN, "liblog",__VA_ARGS__)

           #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, "liblog",__VA_ARGS__)

   3. You can use the LOGD function in the source code.

          LOGD("Debug Message is from JNI");

   4. Add some words in the file "Android.mk" 

          LOCAL_LDLIBS :=  -L$(SYSROOT)/usr/lib -llog

      P.S. I refer some information that tell me add the line under "LOCAL_PATH := $(call my-dir)". When I build the JNI code, the undefined reference always happened. So I move the line above the line "include $(BUILD_SHARED_LIBRARY)", then the error disappeared. I think that the reason is the path of the directory.

累積 | 今日

Powered by Xuite
麗星郵輪石垣島四天三夜那霸克莉貓台東2009華閣生日研究所花蓮礁溪日記阿里山新竹壽豐沖繩初鹿牧場christine鹿野高台津芳中壢android西堤日出阿德南斯愛情宜蘭VS2008日月潭苦悶生日天我是心超人移除HP CQ20潤餅木石噹!我們同在一起白色地中海剃毛Development Serverwasabi國際旅展高美濕地溫泉魚鯉魚潭くろいわSDKPlurkdata mining瑞豐夜市more