没有合适的资源?快使用搜索试试~ 我知道了~
Android NDK 文档(PDF版本)
需积分: 10 16 下载量 140 浏览量
2010-10-09
18:20:10
上传
评论 1
收藏 277KB PDF 举报
温馨提示
试读
84页
Android NDK 文档(PDF版本) 根据最新2.2r4b文档整理。
资源推荐
资源详情
资源评论
Android NDK Installation
Introduction:
-------------
Please read docs/OVERVIEW.TXT to understand what the Android NDK is and is not.
This file gives instructions on how to properly setup your NDK.
I. Requirements:
----------------
The Android NDK currently requires a Linux, OS X or Windows host operating system.
Windows users will need to install Cygwin 1.7 or later (http://www.cygwin.com) to
use the NDK. Note that running it under MSys or Cygwin 1.5 is not supported.
You will need to have the Android SDK and its dependencies installed. The NDK
cannot generate final application packages (.apk files), only the shared library
files that can go into them.
IMPORTANT:
The Android NDK can only be used to target system images using
the Cupcake (1.5) or later releases of the platform.
This is due to subtle toolchain and ABI related changed that make
it incompatible with 1.0 and 1.1 system images.
The NDK requires GNU Make 3.81 or later being available on your development
system. Earlier versions of GNU Make might work but have not been tested.
You can check this by running 'make -v' from the command-line. The output
should look like:
GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
...
On certain systems, GNU Make might be available through a different command like
'gmake' or 'gnumake'. For these systems, replace 'make' by the appropriate command
when invoking the NDK build system as described in the documentation. You might
also want to define the GNUMAKE environment variable to point to it.
The NDK also requires a Nawk or GNU Awk executable being available on your
development system. Note that the original 'awk' program doesn't implement
the 'match' and 'substr' functions used by the NDK build system.
II. Preparing your installation prebuilt cross-toolchain binaries:
------------------------------------------------------------------
Previous releases required you to run the 'build/host-setup.sh' script to
configure the NDK. However, this step has been removed in release 4 (a.k.a. r4).
The auto-detection and sanity checks that were performed by the script have
been moved into the NDK makefiles (and are now performed each time you invoke
GNU Make).
Android NDK Overview
Introduction:
The Android NDK is a set of tools that allows Android application developers
to embed native machine code compiled from C and/or C++ source files into
their application packages.
IMPORTANT:
The Android NDK can only be used to target Android system images
running Cupcake (a.k.a 1.5) or later versions of the platform.
1.0 and 1.1 system images are specifically *not* supported due to
subtle ABI and toolchain changes that happened for the 1.5 release.
I. Android NDK Goals:
---------------------
The Android VM allows your application's source code to call methods
implemented in native code through the JNI. In a nutshell, this means that:
- Your application's source code will declare one or more methods
with the 'native' keyword to indicate that they are implemented through
native code. E.g.:
native byte[] loadFile(String filePath);
- You must provide a native shared library that contains the
implementation of these methods, which will be packaged into your
application's .apk. This library must be named according to standard
Unix conventions as lib<something>.so, and shall contain a standard JNI
entry point (more on this later). For example:
libFileLoader.so
- Your application must explicitely load the library. For example, to load
it at application startup, simply add the following to its source code:
static {
System.loadLibrary("FileLoader");
}
Note that you should not use the 'lib' prefix and '.so' suffix here.
The Android NDK is a complement to the Android SDK that helps you to:
- Generate JNI-compatible shared libraries that can run on the Android
1.5 platform (and later) running on ARM CPUs.
- Copy the generated shared libraries to a proper location of your
application project path, so they will be automatically added to your
final (and signed) .apks
- In later revisions of the NDK, we intend to provide tools that help
debug your native code through a remote gdb connection and as much
source/symbol information as possible.
Moreover, the Android NDK provides:
- A set of cross-toolchains (compilers, linkers, etc..) that can
generate native ARM binaries on Linux, OS X and Windows (with Cygwin)
- A set of system headers corresponding to the list of stable native APIs
supported by the Android platform. This corresponds to definitions that
are guaranteed to be supported in all later releases of the platform.
They are documented in the file docs/STABLE-APIS.TXT
IMPORTANT:
Keep in mind that most of the native system libraries in Android system
images are not frozen and might changed drastically, or even deleted,
in later updates and releases of the platform.
- A build system that allow developers to only write very short build files
to describe which sources need to be compiled, and how. The build system
deals with all the hairy toolchain/platform/CPU/ABI specifics. Moreover,
later updates of the NDK can add support for more toolchains, platforms,
system interfaces without requiring changes in the developer's build
files (more on this later).
II. Android NDK Non-Goals:
--------------------------
The NDK is *not* a good way to write generic native code that runs on Android
devices. In particular, your applications should still be written in the Java
programming language, handle Android system events appropriately to avoid the
"Application Not Responding" dialog or deal with the Android application
life-cycle.
Note however that is is possible to write a sophisticated application in
native code with a small "application wrapper" used to start/stop it
appropriately.
A good understanding of JNI is highly recommended, since many operations
in this environment require specific actions from the developers, that are
not necessarily common in typical native code. These include:
- Not being able to directly access the content of VM objects through
direct native pointers. E.g. you cannot safely get a pointer to a
String object's 16-bit char array to iterate over it in a loop.
- Requiring explicit reference management when the native code wants to
keep handles to VM objects between JNI calls.
The NDK only provides system headers for a very limited set of native
APIs and libraries supported by the Android platform. While a typical
剩余83页未读,继续阅读
资源评论
mypyg
- 粉丝: 3
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功