Game Development Reference
In-Depth Information
Setting Up the NDK
Before we start, we have to install the NDK. This is actually a rather simple process.
Head over to http://developer.android.com/tools/sdk/ndk/index.html
and pick the archive for your platform.
1.
2.
Extract the archive to a location of your liking, and note down its location.
3.
Add the base NDK directory to your system path:
a. On Linux or Mac OS X, open a shell and add the path of the NDK
installation directory to your $PATH environment variable. Generally,
it's in .profile and the line looks like this: export PATH=$PATH:/
path/to/your/ndk/installation
b. On Windows, choose Control Panel ➤ System and Security ➤
System ➤ Advanced System Settings ➤ Environment Variables ➤
System Variables, select Path in the System Variables list, click Edit,
and add the directory to the end of the variable value, starting with a
semicolon (e.g., ;c:\Android_NDK ).
4.
To verify that your NDK has been installed successfully, issue the
command ndk-build in your terminal. It should spit out a few comments
about the lack of an Android project.
In Chapter 2, we set up the JDK and added its bin/ directory to our path.
Make sure the tools in that directory are still available by issuing the
command javah . It should print out the usage information for that tool.
We'll need it later.
5.
Setting Up an NDK Android Project
As in the previous coding chapters, you have to create a new Android project. Copy
over all the framework code from Chapter 12. Then, create a new package called
com.badlogic.androidgames.ndk , place into it a copy of one of the starter activities from
previous chapters, rename it to NdkStarter , and make it the launcher activity. As always,
remember to add any new tests to both the manifest file and the starter activity.
To make things easier, you should open your terminal now and navigate to that new project's
root directory. Make sure your PATH still contains the correct entries so that the ndk-build and
javah tools can be invoked.
 
Search WWH ::




Custom Search