HowBuild an android ndk development environment in UbuntuWhat about it? The following is a step-by-step tutorial.
Step 1. Download ndk (note that I downloaded the R4 version ):
Http://dl.google.com/android/ndk/android-ndk-r4b-linux-x86.zip
Step 2. After the download is complete, decompress it ~ /Directory:
$Echo $ home<-- View the current user directory, that is ~ /Directory path
/Home/wzhnsc
$PWD<-- View the current path
/Home/wzhnsc/android-ndk-r4b
Note: The above path is the android-ndk-r4b-linux-x86.zip directory path after I unzip the android-ndk-r4b
Step 3.First, enter the/home/wzhnsc/android-ndk-r4b directory,
This directory contains a readme. txt file, which mentions:
In the docs/STABLE-APIS.TXT is the APIS documentation,
How to install ndk in docs/install. txt
(Previous versions all need to run build/host-setup.sh for initialization,
This android-ndk-r4b version removes it, it is more convenient to use, Just configure the environment variables as follows ),
How to Use ndk in docs/howto. txt.
Note: It is recommended that you read all these documents for a rough understanding.
Step 4. Configure environment variables for ndk
$Gedit ~ /. Bashrc
Note: add the following content at the end of the opened file:
Ndk = ~ Android-ndk-r4b
Export ndk
Step 5. Read and execute in the current bash environment ~ /. Bashrc command:
$Source ~ /. Bashrc
Or (the source command is also called the "dot command", that is, a dot symbol (.).)
$.~ /. Bashrc
Step 6. Then, check whether it takes effect:
$Echo $ ndk
/Home/wzhnsc/android-ndk-r4b/
Step 7There are two ways to compile:
1) compile in the target project directory:
$CD/home/wzhnsc/android-ndk-r4b/samples/Hello-JNI
Enter the example directory
$Ndk/ndk-build
Then run the/home/wzhnsc/android-ndk-r4b/ndk-build script in the current directory
2) Compile in any directory:
$Ndk/ndk-Build-C/home/wzhnsc/android-ndk-r4b/samples/Hello-JNI
Use-C to point out the project directory path
Note: No matter which one is compiled, after successful compilation, the libs and OBJ subdirectories will be generated in the current directory.
Step 8. Open eclipse and import the hello-JNI project to see the effect.