Installing Android development tools on Windows
To start developing games for Android you will need some essential tools to be installed on your system.
Getting ready
Here is the list of all the prerequisites you will need to start developing games for Android:
- Android SDK at http://developer.android.com/sdk/index.html.
- Android NDK at http://developer.android.com/tools/sdk/ndk/index.html (we used Android NDK r9b).
- Apache Ant at http://ant.apache.org. This is a Java command-line tool which may be unfamiliar to C++ developers. It's purpose is to build Java applications, and since every Android application has a Java wrapper, this tool will help us to pack them into archives ready for deployment (these are called
.apk
packages, which stands for Android Package). - Java SE Development Kit at http://www.oracle.com/technetwork/java/javase/downloads/index.html.
Former versions of SDK/NDK for Windows required a Cygwin environment, a Linux-like environment for Windows, to be installed. Up-to-date versions of these tools can run natively on Windows without any intermediate layer. We will focus on the Cygwin-less environment and will do all of the development without IDE. You heard it right, we will just use the command line. All the examples in this book were written and debugged on a Windows PC.
To compile native Windows applications presented in this book, you will need a decent C++ compiler, such as the MinGW package with a GCC toolchain. Using Microsoft Visual Studio is also possible.
How to do it...
- Android SDK and NDK should be installed into folders that do not contain any whitespaces in their names.
Note
This requirement comes from the limitations of scripts in Android SDK. There is a nice discussion on StackOverflow which explains some reasons behind these limitations at http://stackoverflow.com/q/6603194/1065190.
- Other tools can be installed to their default locations. We used the following paths in our Windows 7 system:
All tools have pretty decent GUI installers (see the following image, that shows the Android SDK Manager from SDK R21) so you don't have to use the command line.
For the Windows environment, you need the MinGW GCC toolchain. The easy to install all-in-one package can be found at http://www.equation.com, in the Programming Tools section, Fortran, C, C++ subsection. Alternatively, you can download the official installer from http://www.mingw.org. We will use the one from www.equation.com
There's more...
You need to set some environment variables to let the tools know where the files are located. The JAVA_HOME
variable should point to the Java Development Kit folder. The NDK_HOME
variable should point to the Android NDK installation folder, and ANDROID_HOME
should point to the Android SDK folder (note the double backslash). We used the following environment variable values:
JAVA_HOME=D:\Java\jdk1.6.0_23
NDK_HOME=D:\ndk
ANDROID_HOME=D:\\android-sdk-windows
The final configuration looks similar to the one shown in the following screenshot, which shows the Windows Environment Variables dialog box:
After MinGW has been successfully installed, you should also add the bin
folder from its installation folder to the PATH
environment variable. For example, if MinGW is installed to C:\MinGW
, then PATH
should contain the C:\MinGW\bin
folder.