如何使用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编译时添加库第三方库文件

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文件中添加上述代码 可以在编译时将
android/customization/custom_normal/vendor/third-party/libs/libhello-jni.so 库文件添加到android系统库目录中

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-jniubuntu@ubuntu-desktop:~/android/ToolsForLinux/android-ndk-r4b/samples/hello-jni$ ../../ndk-build -B v=1Gdbserver      : [arm-eabi-4.4.0] /home/ubuntu/android/ToolsForLinux/android-ndk-r4b/samples/hello-jni/libs/armeabi/gdbserverGdbsetup       : /home/ubuntu/android/ToolsForLinux/android-ndk-r4b/samples/hello-jni/libs/armeabi/gdb.setupGdbsetup       : + source directory /home/ubuntu/android/ToolsForLinux/android-ndk-r4b/samples/hello-jni/jniCompile thumb  : hello-jni <= /home/ubuntu/android/ToolsForLinux/android-ndk-r4b/samples/hello-jni/jni/hello-jni.cSharedLibrary  : libhello-jni.soInstall        : libhello-jni.so => /home/ubuntu/android/ToolsForLinux/android-ndk-r4b/samples/hello-jni/libs/armeabiubuntu@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-jniAndroid NDK: Building for application 'hello-jni'    Gdbserver      : [arm-eabi-4.4.0] /home/ubuntu/android/ToolsForLinux/android-ndk-r4b/apps/hello-jni/libs/armeabi/gdbserverGdbsetup       : /home/ubuntu/android/ToolsForLinux/android-ndk-r4b/apps/hello-jni/libs/armeabi/gdb.setupGdbsetup       : + source directory /home/ubuntu/android/ToolsForLinux/android-ndk-r4b/apps/hello-jni/jniCompile thumb  : hello-jni <= /home/ubuntu/android/ToolsForLinux/android-ndk-r4b/apps/hello-jni/jni/hello-jni.cSharedLibrary  : libhello-jni.soInstall        : libhello-jni.so => /home/ubuntu/android/ToolsForLinux/android-ndk-r4b/apps/hello-jni/libs/armeabiubuntu@ubuntu-desktop:~/android/ToolsForLinux/android-ndk-r4b$



更多相关文章

  1. 如何在Android(安卓)NDK中调用第三方库文件(.so)
  2. Android代码实现WiFi连接
  3. 【Android】Tips for Android(安卓)developer: “Conversion to
  4. android 清空之前task中的activity
  5. Android(安卓)Studio将本地计算机文件上传到模拟器scard文件中
  6. Android(安卓)常见错误处理
  7. [Android(安卓)Training视频系列] 6.2 Saving Files(保存文件)
  8. android开玩笑之创建xml文件
  9. 自定义radio,尊重原创,声明此文章为转载

随机推荐

  1. Android(安卓)重读官方文档 4 SharedPref
  2. Android三种常用动画分享(转)
  3. Android独立闹钟实现
  4. 支付宝
  5. Android EditText 禁止点击 弹键盘
  6. Android 使用后台线程
  7. Android GMS Crash 优化方案
  8. Broadcast使用场景解读
  9. Android JUnit Test——批量运行测试代码
  10. GitHub Android 开源项目汇总