Mastering Android NDK
上QQ阅读APP看书,第一时间看更新

Using Android command-line tools on Windows

To start developing native C++ applications for Android in a Microsoft Windows environment, you will need some essential tools to be installed on your system.

Start NDK development for Android using the following list of all the prerequisites you will need:

The current versions of these tools will run on Windows without using any intermediate compatibility layer; they do not require Cygwin any more.

As much as it pains us to write this, Android SDK and NDK should still be installed into folders that do not contain any whitespaces in their names. This is a limitation of build scripts within the Android SDK; the unquoted environment variables content are split into words based on tab, space and newline characters.

We will install the Android SDK to D:\android-sdk-windows, the Android NDK to D:\ndk, and other software to their default locations.

In order to compile our portable C++ code for Windows, we need a decent toolchain. We recommend using the latest version of the MinGW from the Equation package available at http://www.equation.com. You can choose 32- or 64-bit versions as you go.

Once all the tools are in their folders, you need to set environment variables to point to those install locations. The JAVA_HOME variable should point to the Java Development Kit folder:

JAVA_HOME="D:\Program Files\Java\jdk1.8.0_25"

The NDK_HOME variable should point to the Android NDK installation folder:

NDK_HOME=D:\NDK

The ANDROID_HOME should point to the Android SDK folder:

ANDROID_HOME=D:\\android-sdk-windows

Note

Note the double backslash in the last line.

Both NDK and SDK will have new versions from time to time, so it might be helpful to have the version number on the folder name and manage NDK folders per project if necessary.