jni中native通过adb输出
本文主要實踐了如何在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");
?
總結
以上是生活随笔為你收集整理的jni中native通过adb输出的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 用51单片机和esp8266实现通过手机
- 下一篇: IDEA 学习笔记之 安装和基本配置