本文主要实践了如何在jni中打印log,贴源码:
Android.mk主要是巴拉的android源码中的app
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
#TARGET_PLATFORM := android-3
#LOCAL_SDK_VERSION := 19
LOCAL_MODULE := libnative
LOCAL_SRC_FILES := FactoryTestjni.cpp
LOCAL_MODULE_TAGS := optional
LOCAL_LDLIBS :=-llog
include $(BUILD_SHARED_LIBRARY)
其中LOCAL_LDLIBS :=-llog 这是灵魂哈对于log功能
c文件中是这个样式的:#include "FactoryTestjni.h"
#include <string.h>
#include <jni.h>
#include <dlfcn.h>
#include <dirent.h>
#include <errno.h>
#include <sys/stat.h>
#include <stdio.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <termios.h>
#include <stdlib.h>
#include <strings.h>
#include <android/log.h>
#define LOG_TAG "Fuck you" // 这个是自定义的LOG的标识
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)/*
代码调用使用 : LOGI("run here");
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)