Android HAL
2010-04-21 06:36:00 来源:WEB开发网if (vm->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) {
LOGE("ERROR: GetEnv failed ");
goto fail;
}
assert(env != NULL);
if (registerMethods(env) != 0) {
LOGE("ERROR: PlatformLibrary native registration failed ");
goto fail;
}
/* success -- return valid version number */
result = JNI_VERSION_1_4;
fail:
return result;
}
Android.mk 文件:
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
#LOCAL_MODULE_TAGS := eng
# This is the target being built.
LOCAL_MODULE:= libled_runtime
# All of the source files that we will compile.
LOCAL_SRC_FILES:=
com_hello_LedService.cpp
# All of the shared libraries we link against.
LOCAL_SHARED_LIBRARIES :=
libandroid_runtime
libnativehelper
libcutils
libutils
libhardware
# No static libraries.
LOCAL_STATIC_LIBRARIES :=
# Also need the JNI headers.
LOCAL_C_INCLUDES +=
$(JNI_H_INCLUDE)
# No specia compiler flags.
LOCAL_CFLAGS +=
# Don't prelink this library. For more efficient code, you may want
# to add this library to the prelink map and set this to true.
LOCAL_PRELINK_MODULE := false
include $(BUILD_SHARED_LIBRARY)
将 Led stub , LedService 相关文件放到 development/my_module 分别 make 即可生成相应的 so 文件。使用 adb push 命令安装到虚拟机上运行即可。
文件组织机构如下:
a@ubuntu:~/work/android/source_android/development/my_module$ pwd
/home/a/work/android/source_android/development/my_module
a@ubuntu:~/work/android/source_android/development/my_module$ tree hal
hal
更多精彩
赞助商链接