Eclipse: Problems with JNI code debugging
Backgro开发者_开发百科und
I'm writing application for android, using Eclipse in Windows. I'm implementing C code in JAVA and for that I'm using JNI. I have many functions and my problem is that I want to debug functions in JNI.
Question
Can I debug my code which is written in JNI in C language ?
Here is answer How to start logging for Android NDK !
Some weeks I was researching how I can write logs in Eclipse from Android NDK code. I found some examples in Internet and want to share it with you. Following steps below you can start logging on Eclipse.
Include log.h file into your Android NDK source file
#include <android/log.h>
Add the line below to your Android.mk make file.
LOCAL_LDLIBS := -llog
Now you can start logging, this two steps allows you to write logs in Eclipse from Android NDK. Write the line below in your Android NDK code and the log will bw appear in the Eclipse
__android_log_write(ANDROID_LOG_ERROR,"Tag","Message");
use following Flags to write logs in the column which you want.
typedef enum android_LogPriority {
ANDROID_LOG_UNKNOWN = 0,
ANDROID_LOG_DEFAULT, /* only for SetMinPriority() */
ANDROID_LOG_VERBOSE,
ANDROID_LOG_DEBUG,
ANDROID_LOG_INFO,
ANDROID_LOG_WARN,
ANDROID_LOG_ERROR,
ANDROID_LOG_FATAL,
ANDROID_LOG_SILENT, /* only for SetMinPriority(); must be last */
} android_LogPriority
For example if you want to write in Info column you must write
__android_log_write(ANDROID_LOG_INFO,"Tag","Message");
So, Good Luck !
精彩评论