Objective
This blog will show you how to install the Android NDK under Ubuntu12.04, and in other versions of Ubuntu, the method is similar. Since the Android NDK cannot be run alone as an Android application, you must first install the Android SDK before using the Android NDK developer program.
The main content of this blog:
- Preparatory work
- Installing the NDK
Preparatory work
You must first get the Android NDK installation files, which can be obtained directly on Android's official website, click to download. Because this is using Ubuntu 32-bit, download android-ndk-r9d-linux-x86.tar.bz2. Such as:
After the download is complete, you will get a compressed package with the suffix tar.bz2, which can be decompressed under Ubuntu.
Installing the NDK
After you get the TAR.BZ2 package, you need to decompress the package. Because tar is the standard compression format, you can use Ubuntu graphics to unzip, right-click → extract here, you can unzip it under the current folder to get a android-ndk-r9d folder. In addition to using the image method provided by Ubuntu, you can also extract a android-ndk-r9d folder under the terminal using the TAR statement. The currently downloaded installation file is under the Developer folder with the following statement:
~/developer$ Tar jxvf android-ndk-r9d-linux-x86.tar.bz2
After the decompression is complete, you also need to configure the NDK's environment variables. There are two options, if you modify the. profile file under the current User name home folder, this configuration is only valid for the currently logged-on user, and you can modify the/etc/profile file if you need to be valid for all users of the computer. Here you use the Gedit command, as follows:
To modify the currently logged on user profile:
To modify the system configuration file:
~$ sudo gedit/etc/profile
Both commands open a profile file in which the system configuration file is modified, such as:
At the end of the add, and save close:
Export Android_ndk=/home/bgxtand/developer/android-ndk-r9dexport path= $ANDROID _NDK: $PATH
The path to the NDK here is/home/bgxtand/developer, which can be viewed using the PWD command if the specific path is not determined. Such as:
After saving the profile file, you also need to re-load the profile file, where you can use the following two commands to enable Ubuntu to reload the profile file, the following two ways can be:
Use the source command:
~$ Source/etc/profile
Use the. Command:
~$ . /etc/profile
To configure the NDK's environment variables, you can use the Echo $PATH command to view the current environment variable values and ensure that the current NDK directory has been added to the environment variable as follows:
By this time to complete the installation of the NDK under Ubuntu, the NDK contains a lot of sample code, in order to verify that the NDK installation is successful, you can enter the ~/android-ndk-r9d/samples/hello-jni/jni directory, execute the ndk-build command , the effect is as follows:
After executing the ndk-build command, there is an output indicating that the Ubuntu NKD installation is successful.