调试android通过jni调用的C++代码
2012-02-24 16:57
615 查看
1、头文件
#include <android/log.h>2、宏定义
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, "mytest", __VA_ARGS__)3、代码中打印
LOGD("test test test"); int i = 12; LOGD("%d",i);4、注意打印字符串可以用下面两个函数
__android_log_print
__android_log_write
但是打印整数等,就必须用下面这个函数了
__android_log_print
原因参见文件/system/core/include/android/log.h,如下
#include <stdarg.h> #ifdef __cplusplus extern "C" { #endif /* * Android log priority values, in ascending priority order. */ 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; /* * Send a simple string to the log. */ int __android_log_write(int prio, const char *tag, const char *text); /* * Send a formatted string to the log, used like printf(fmt,...) */ int __android_log_print(int prio, const char *tag, const char *fmt, ...) #if defined(__GNUC__) __attribute__ ((format(printf, 3, 4))) #endif ; /* * A variant of __android_log_print() that takes a va_list to list * additional parameters. */ int __android_log_vprint(int prio, const char *tag, const char *fmt, va_list ap); /* * Log an assertion failure and SIGTRAP the process to have a chance * to inspect it, if a debugger is attached. This uses the FATAL priority. */ void __android_log_assert(const char *cond, const char *tag, const char *fmt, ...) #if defined(__GNUC__) __attribute__ ((noreturn)) __attribute__ ((format(printf, 3, 4))) #endif ; #ifdef __cplusplus } #endif #endif /* _ANDROID_LOG_H */
相关文章推荐
- Android(安卓)开发通过NDK调用JNI,使用opencv做本地c++代码开发配置方法实现边缘检测代码(2)
- Android(安卓)开发通过NDK调用JNI,使用opencv做本地c++代码开发配置方法 边缘检测 范例代码
- [转]Android通过NDK调用JNI,使用opencv做本地c++代码开发配置方法
- Android 学习笔记——利用JNI技术在Android中调用、调试C++代码
- Android(安卓)开发通过NDK调用JNI,使用opencv做本地c++代码开发配置方法 边缘检测 范例代码
- Android App中通过JNI调用C/C++代码(二)
- 利用JNI技术在Android中调用、调试C++代码
- Android 学习笔记——利用JNI技术在Android中调用、调试C++代码
- 利用JNI技术在Android中调用、调试C++代码
- android中如何通过jni调用c,c++代码
- Android:通过JNI调用c++代码
- 利用JNI技术在Android中调用C、调试C++代码(工具,详解)
- Android 学习笔记——利用JNI技术在Android中调用、调试C++代码
- Android 学习笔记——利用JNI技术在Android中调用、调试C++代码
- Android 学习笔记——利用JNI技术在Android中调用、调试C++代码
- [转][android][利用JNI技术在Android中调用、调试C++代码]
- Android 学习笔记——利用JNI技术在Android中调用、调试C++代码
- [安卓开发笔记二]android Studio通过jni调用C++代码
- Android 学习笔记——利用JNI技术在Android中调用、调试C++代码
- Android 学习笔记——利用JNI技术在Android中调用、调试C++代码