如何使用java的NDK轻松调用C或者C++函数库
一 Android添加自己的动态库
在 build/core/prelink-linux-arm.map 或者build/core/prelink-linux-mips.map 加入自己的动态库的定义
二
原文网址:http://macholad-hotmail-com.javaeye.com/blog/889022
android/customization/custom_normal/vendor/third-party/libs/Android_cust.mk 中
include $(CLEAR_VARS) LOCAL_PREBUILT_LIBS += libhello-jni.so include $(BUILD_MULTI_PREBUILT)在上述mk文件中添加上述代码 可以在编译时将
三
1 进入工程的目录然后使用 $(NDK)/ndk-build
ubuntu@ubuntu-desktop:~/android/ToolsForLinux/android-ndk-r4b/samples/hello-jni$ pwd /home/ubuntu/android/ToolsForLinux/android-ndk-r4b/samples/hello-jni ubuntu@ubuntu-desktop:~/android/ToolsForLinux/android-ndk-r4b/samples/hello-jni$ ../../ndk-build -B v=1 Gdbserver : [arm-eabi-4.4.0] /home/ubuntu/android/ToolsForLinux/android-ndk-r4b/samples/hello-jni/libs/armeabi/gdbserver Gdbsetup : /home/ubuntu/android/ToolsForLinux/android-ndk-r4b/samples/hello-jni/libs/armeabi/gdb.setup Gdbsetup : + source directory /home/ubuntu/android/ToolsForLinux/android-ndk-r4b/samples/hello-jni/jni Compile thumb : hello-jni <= /home/ubuntu/android/ToolsForLinux/android-ndk-r4b/samples/hello-jni/jni/hello-jni.c SharedLibrary : libhello-jni.so Install : libhello-jni.so => /home/ubuntu/android/ToolsForLinux/android-ndk-r4b/samples/hello-jni/libs/armeabi ubuntu@ubuntu-desktop:~/android/ToolsForLinux/android-ndk-r4b/samples/hello-jni$
2 in apps
a) make file pplication.mk
其中Application.mk 如下:
APP_PROJECT_PATH := /home/ubuntu/android/ToolsForLinux/android-ndk-r4b/apps/hello-jni
b)
ubuntu@ubuntu-desktop:~/android/ToolsForLinux/android-ndk-r4b$ ubuntu@ubuntu-desktop:~/android/ToolsForLinux/android-ndk-r4b$ make APP=hello-jni Android NDK: Building for application 'hello-jni' Gdbserver : [arm-eabi-4.4.0] /home/ubuntu/android/ToolsForLinux/android-ndk-r4b/apps/hello-jni/libs/armeabi/gdbserver Gdbsetup : /home/ubuntu/android/ToolsForLinux/android-ndk-r4b/apps/hello-jni/libs/armeabi/gdb.setup Gdbsetup : + source directory /home/ubuntu/android/ToolsForLinux/android-ndk-r4b/apps/hello-jni/jni Compile thumb : hello-jni <= /home/ubuntu/android/ToolsForLinux/android-ndk-r4b/apps/hello-jni/jni/hello-jni.c SharedLibrary : libhello-jni.so Install : libhello-jni.so => /home/ubuntu/android/ToolsForLinux/android-ndk-r4b/apps/hello-jni/libs/armeabi ubuntu@ubuntu-desktop:~/android/ToolsForLinux/android-ndk-r4b$