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 Android SDK: You can find this at http://developer.android.com/sdk/index.html. We use revision 24.
- The Android NDK: You can find this at http://developer.android.com/tools/sdk/ndk/index.html. We use version r10e.
- The Java Development Kit (JDK): You can find this at http://www.oracle.com/technetwork/java/javase/downloads/index.html. We use Oracle JDK Version 8.
- Apache Ant: You can find this at http://ant.apache.org. This is a tool used to build Java applications.
- Gradle: You can find this at https://www.gradle.org. Compared to Ant, this is a more modern Java build automation tool capable of managing external dependencies.
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
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.