Android ndk开发之在c文件里打印log
2014-03-09 16:27
453 查看
There are three step in total
step one:add "LOCAL_LDLIBS := -llog " to your android.mk file
like:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_LDLIBS := -llog
LOCAL_MODULE := hellolog
LOCAL_SRC_FILES := native.c
include $(BUILD_SHARED_LIBRARY)
step two:
include <android/log.h> as header in you c file, and define LOG_TAG、LOGE(...)like:
#include <android/log.h>
#define LOG_TAG "plus.c"
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
you can also define a yourlog.h file, define all kinds of log, then include this into your c file, like:
=====mylog.h=======
#include <jni.h>
#include <android/log.h>
#define LOG_TAG "hgllog.h"
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
#define LOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)
step three:
use yourself define LOGE() print info as you want, like:
LOGE("this is log info string....");
LOGE("this is log info string.... and str is %s", str);
相关文章推荐
- android ndk开发打印Log的方法
- NDK开发中Eclipse自动编译C文件配置及Log信息打印
- Android studio中JNI-NDK开发打印LOG出现 undefined reference to `__android_log_print' 解决
- Android NDK(学习笔记四)—— 在NDK开发中JNI打印Log信息
- android ndk打印log信息
- android ndk 入门之打印log信息
- Android NDK开发(三)——常见错误集锦以及LOG使用,androidndk
- 酷派手机(Coolpad 8297-T01)在Android开发工具如AndroidStudio、Eclipse中无法打印Log
- [置顶] Android开发之封装log打印日志的工具类,实用logutils详细代码
- Android Jni开发之创建Jni程序和打印log
- Android开发之封装log打印日志的工具类,实用logutils详细代码
- Android NDK 开发(三)--常见错误锦集合Log的使用【转】
- android ndk 入门之打印log信息
- Visual GDB进行Android NDK开发,报错:error : undefined reference to '__android_log_print' 解决办法
- 安卓开发解决不打印log日志方法
- 封装一个简单好用的打印Log的工具类And快速开发系列 10个常用工具类
- android ndk开发之Log日志(二)
- Android开发,测试机不打印Log的解决办法
- 设计并实现一个LogService,应用开发时可以打印log到视图(TextView)中显示
- Android.util.Log 关于Android开发中打印log