Android applicationsProgramThey are all developed in Java. Android ndk enables us to use C/C ++ native development on AndroidCode.
There are two reasons to use ndk: one is to rationally reuse existing code, and the other is to improve the execution efficiency in some key parts of the program.
For Android ndk development, in addition to the general Android development environment, you also need to download the ndk package and install the cygwin tool (required in Windows ).
Cygwin is a Windows environment similar to Linux. It includes a DLL that provides a basic subset of UNIX functionality and a set of tools above it. (This is not required in Linux)
To install cygwin, follow these steps:
Go to official websiteWww.cygwin.comIn the center of the screen is a black-green "C" logo with the title "install or update now .". Click on the link to download a small program setup.exe (250kb ). This installer will guide the cygwin environment installation or update process on your machine.
2.run setup.exe to installInstallation, such:
Figure 1. Installation Wizard of cygwin Environment
Select Download location
On this page, select "Install from Internet ".
Figure 2. Select the installation type
Keep clickingNextButton until the page appears:
Select a download site. Because these sites are obligated images, it is risky to select a download point (usually they are available but sometimes unavailable ). Generally, try the site that is closer to you. (There is one http://mirrors.163.com fastest)
Select a package for Installation
On this page, you will select the package to install. By default, GCC is not installed in the cygwin basic package. Therefore, you must modify the default settings.
Move the mouse overDevelOn the plus sign (+) of the edge, click it to expandDevelClass.
In this step, we select the component package to be downloaded. To enable cygwin to compile the program, we need to install the GCC compiler. By default, GCC will not be installed, we need to select it for installation. To install GCC, click the "devel" branch in the component list. There are many components under this branch. What we need is:
Click the cycle button in front of the component to display the build version date. Select the latest version for installation. The four types of components are selected:
After the selection, select next to go to the installation process, as shown in,
After the download is complete, it will be OK!
3. test whether the installation is successful.
Run cygwin and enter make-V and GCC-V. If you can find them, the installation is successful.
It is easy to install ndk. You only need to extract the downloaded ndk file to the specified directory.
Modify the. bash_profile file under the cygwin directory/home/username and add the following code at the end of the file:
Ndkroot=/Cygdrive/Path of the ndk file (such as ndkroot =/cygdrive/D/Android/ndk)
(Note: The ndkroot name can be used by yourself. The path of the ndk file is the path of the ndk after decompression. Note that you should change the Slash to a backslash and remove the path difference between Windows and Linux ))