1. 在 hello-jni.c文件
#include <string.h>
#include <jni.h>
#include <android/log.h>
#define LOG_TAG "mylog"
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
/* This is a trivial JNI example where we use a native method
* to return a new VM String. See the corresponding Java source
* file located at:
*
* apps/samples/hello-jni/project/src/com/example/hellojni/HelloJni.java
*/
jstring
Java_com_example_jni_HFHelloJni_stringFromJNI( JNIEnv* env,
jobject thiz )
{
LOGI("debug log success\n");
return (*env)->NewStringUTF(env, "Hello from JNI !");
}
2. Android.mk文件
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := hello-jni
LOCAL_SRC_FILES := hello-jni.c
LOCAL_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)