Build an android ndk development environment in Ubuntu

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.