找回密码
 立即注册
AndroidTheNDK使用 | android开发 2022-10-26 42 0star收藏 版权: . 保留作者信息 . 禁止商业使用 . 禁止修改作品
1、前语??6月26日,GoogleAndroid发布了NDK,引起了很多发人员的爱好。NDK全称:NativeDevelopmentKit。下载地址为:developer.android/sdk/ndk/1.5_r1/index.html。2、误解??新出世的事物,除了惊喜外,也会给我们带来一定的利诱、误解。2.1、误解一:NDK发布之前,Android不支持进行C开发??在Google中查找“NDK”,很多“Android总算可以使用C++开发”之类的标题,这是一种对Android平台编程方法的误解。本来,Android平台从诞生起,就现已支持C、C++开发。尽人皆知,Android的SDK基于Java实现,这意味着基于AndroidSDK进行开发的第三方使用都必须使用Java语言。但这并不等同于“第三方使用只能使用Java”。在AndroidSDK初次发布时,Google就声称其虚拟机Dalvik支持JNI编程方法,也即是第三方使用完全可以通过JNI调用自己的C动态库,即在Android平台上,“Java+C”的编程方法是一向都可以实现的。??当然这种误解的生成是有本源的:在AndroidSDK文档里,找不到任何JNI方面的帮助。即使第三方使用开发者使用JNI实现了自己的C动态链接库(so)开发,可是so如何和使用程序一同打包成apk并发布?这里面也存在技术障碍。我从前花了不少时刻,安装穿插编译器创建so,并通过asset(资源)方法,实现捆绑so发布。但这种方法只能归于取巧的方法,并非官方支持。所以,在NDK出来之前,我们将“Java+C”的开发模式称之为灰色模式,即官方既不声明“支持这种方法”,也不声明“不支持这种方法”。2.2、误解二:有了NDK,我们可以使用纯C开发Android使用??AndroidSDK选用Java语言发布,把很多的C开发人员排除在第三方使用开发外(注意:我们一切评论都是基于“第三方使用开发”,Android系统基于Linux,系统级别的开发肯定是支持C语言的。)。NDK的发布,很多人会误以为,类似于Symbian、WM,在Android平台上总算可以使用纯C、C++开发第三方使用了!本来不然,NDK文档清晰说明:itisnotagoodway。由于NDK并没有提供各种系统事情管理支持,也没有提供使用程序生命周期保护。此外,在本次发布的NDK中,使用程序UI方面的API也没有提供。最少目前来说,使用纯C、C++开发一个完整使用的条件还不完备。3、NDK是啥对NDK进行了大略的研究后,我对“NDK是啥”的理解如下:1、NDK是一系列工具的集合。NDK提供了一系列的工具,帮助开发者快速开发C(或C++)的动态库,并能自动将so和java使用一同打包成apk。这些工具对开发者的帮助是无穷的。NDK集成了穿插编译器,并提供了相应的mk文件阻隔CPU、平台、ABI等区别,开发人员只需求简单修复mk文件(指出“哪些文件需求编译”、“编译特性请求”等),就可以创建出so。NDK可以自动地将so和Java使用一同打包,极大地减轻了开发人员的打包工作。2、NDK提供了一份安稳、功能有限的API头文件声明。??Google清晰声明该API是安稳的,在后续一切版本中都安稳支持当时发布的API。从该版本的NDK中看出,这些API支持的功能非常有限,包括有:C规范库(libc)、规范数学库(libm)、压缩库(libz)、Log库(liblog)。4、NDK带来啥1、NDK的发布,使“Java+C”的开发方法总算转正,成为官方支持的开发方法。使用NDK,我们可以将请求高性能的使用逻辑使用C开发,从而提升使用程序的履行效率。使用NDK,我们可以将需求保密的使用逻辑使用C开发。究竟,Java包都是可以反编译的。NDK促使专业so组件商的出现。(达观猜测,要视乎Android用户的数量)2、NDK将是Android平台支持C开发的初步。??NDK提供了的开发工具集合,使开发人员可以快捷地开发、发布C组件。一起,Google承诺在NDK后续版本中提升“可调式”才能,即提供远程的gdb工具,使我们可以快捷地调试C源码。在支持Android平台C开发,我们能感觉到Google花费了很大精力,我们有理由神往“C组件支持”仅仅GoogleAndroid平台上C开发的初步。究竟,C程序员仍然是码农阵营中的肯定主力,将这部分人排除在Android使用开发以外,显然是不利于Android平台繁荣昌盛的。本资料共包括以下附件:
Android面试题.doc
宝软AppStore客户端交互协议_V0.3.doc
说一下你眼里的Android的优点和不足之处.txt
谈谈你对AndroidNDK的理解.txt
标题-图片下载和显示.doc
.....

(1. Preface?? On June 26, Google Android released NDK, which attracted many developers. Full name of NDK: NativeDevelopmentKit. The download address is: developer.android/sdk/ndk/1.5_ r1/index. html。 2. Misunderstandings?? In addition to surprises, new things will also bring us some inducements and misunderstandings. 2.1 Misunderstanding 1: Android does not support C development before the NDK is released?? Look up "NDK" in Google, and many titles like "Android can finally be developed using C  ", which is a misunderstanding of Android platform programming methods. Originally, the Android platform has supported C and C  development since its birth. As we all know, the Android SDK is implemented based on Java, which means that third parties who develop based on the Android SDK must use the Java language. But this is not the same as "the third party can only use Java". When the Android SDK was first released, Google claimed that its virtual machine Dalvik supports JNI programming methods, that is, third parties can call their own C dynamic library through JNI, that is, on the Android platform, the "Java C" programming method is always possible.?? Of course, this misunderstanding is rooted in the fact that no JNI help can be found in the Android SDK documentation. Even though the third-party developers use JNI to implement their own C dynamic link library (so) development, how can so be packaged into an apk and released together with the user program? There are also technical barriers. In the past, I spent a lot of time installing the interposition compiler to create so, and using the asset method to achieve bundled so release. However, this method can only be attributed to ingenuity, not official support. Therefore, before the NDK came out, we called the "Java C" development mode as the gray mode, that is, the official statement neither "support this method" nor "do not support this method". 2.2 Misunderstanding 2: With NDK, we can use pure C to develop Android?? The Android SDK is released in the Java language, which excludes many C developers from third-party use and development. (Note: All our comments are based on "third-party use and development". The Android system is based on Linux, and system level development must support the C language.). With the release of NDK, many people will mistakenly believe that, similar to Symbian and WM, it is finally possible to use pure C and C  to develop third-party applications on the Android platform! Otherwise, the NDK document clearly states that it is not a tool way. Because NDK does not provide various system event management support, nor does it provide application lifecycle protection. In addition, in the NDK released this time, the API for user UI is not provided. At least for now, the conditions for developing a complete use of pure C and C  are not complete. 3. What is NDK After a general study of NDK, my understanding of "what is NDK" is as follows: 1. NDK is a collection of tools. NDK provides a series of tools to help developers quickly develop C (or C  ) dynamic libraries, and can automatically package so and java together into apks. These tools can help developers endlessly. NDK integrates the interposition compiler and provides the corresponding mk files to block the differences between CPU, platform, ABI, etc. Developers only need to simply repair the mk files (point out "which files need to be compiled", "compilation feature requests", etc.) to create so. NDK can automatically package so and Java together, greatly reducing the packaging work of developers. 2. NDK provides a stable and limited API header file declaration.?? Google clearly states that the API is stable and supports the API released at that time in all subsequent versions. From this version of NDK, we can see that the functions supported by these APIs are very limited, including the C specification library (libc), the specification math library (libm), the compression library (libz), and the Log library (liblog). 4. What does NDK bring? 1. The release of NDK has finally turned the "Java C" development method into an official supported development method. With NDK, we can use C to develop the use logic for high performance requests, thus improving the performance of the user program. With NDK, we can use C to develop the confidential usage logic. After all, Java packages can be decompiled. NDK promotes the emergence of professional so component manufacturers. (Da Guan guesses that it depends on the number of Android users) 2. NDK will be the initial stage for Android platform to support C development.?? NDK provides a collection of development tools that enable developers to quickly develop and publish C components. Together, Google promises to improve the "adjustable" ability in the subsequent versions of NDK, that is, to provide remote gdb tools so that we can quickly debug C source code. In supporting C development on the Android platform, we can feel that Google has spent a lot of energy. We have reason to be fascinated that "C component support" is only the initial stage of C development on the Google Android platform. After all, C programmers are still code farmers)

[下载]11070355053.rar




上一篇:Android开发环境搭建
下一篇:Android SDK r09 mac x86版