Android Studio NDK基础使用

NDK是什么?

Android平台是基于java实现,运行于虚拟机Dalvik;故而使用Android SDK创建应用程序需要使用java语言来编写实现。不过并不仅限于使用java,google在发布android之初就宣称支持持JNI编程方式,也就是第三方应用完全可以通过JNI调用自己的C动态库,即在Android平台上,“Java+C”的编程方式是一直都可以实现的。NDK即为了方便你创建应用时调用本地C/C++的一系列工具集合。
The NDK is a toolset that allows you to implement parts of your app using native-code languages such as C and C++. For certain types of apps, this can be helpful so you can reuse existing code libraries written in these languages, but most apps do not need the Android NDK.

官方NDK文档:http://wear.techbrood.com/tools/sdk/ndk/

什么时候使用NDK?

Before downloading the NDK, you should understand that the NDK will not benefit most apps. As a developer, you need to balance its benefits against its drawbacks. Notably, using native code on Android generally does not result in a noticable performance improvement, but it always increases your app complexity. In general, you should only use the NDK if it is essential to your app—never because you simply prefer to program in C/C++.
官方清楚的描述了大部分应用并不会因为使用NDK而获得明显的性能收益,反而有可能导致应用的复杂度增加,兼容性变差等。Google建议在需要在处理需要大量计算/高CPU消耗的工作时使用NDK来提高运算处理效率,例如:游戏引擎、信号处理、图像处理等。

而实际使用NDK时往往还会考虑到:
1. 代码的保护,由于apk的java层代码很容易被反编译,而C/C++库反汇难度较大。

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值