Configure the Android NDK development environment in Mac OS X
1. Before reading the following, make sure that the development environment of your Android sdk has been set up, and the ADT should be the latest.
2. download the latest ndk at http://developer.android.com/tools/sdk/ndk/index.html.
3. decompress the downloaded file.
4. Configure your. bash_profile. Open the terminal and enter the command pico. bash_profile.
Add a row of export PATH =$ {PATH}:/Users/jarrahwu/Documents ents/android-ndk-r8d first
Then a line of A_NDK_ROOT =/Users/jarrahwu/Documents/android-ndk-r8d
Last line export A_NDK_ROOT
This is actually equivalent to saving the environment variable contrl + x in windows, then entering Y to confirm, and finally entering enter. Finally, close the terminal and open it again.
For more information, see my uploaded images.
If the above configuration is correct, you can prepare to write an ndk hello world.
(1) first, create a project named MyNDK, just like setting up an android project.
(2) configure the android NDK path. The specific operation is-> eclipse-> preferences-> android-> NDK, and then configure your NDK path.
(3) If you are not the latest ADT, you may need to use the javah command on the terminal to add NDK support, create folders, and so on, however, the latest ADT already contains some columns for these operations. you can simply add NDK support.
Right-click your project and choose android tools> Add Native Support .. all of a sudden OK. if your eclipse cannot view the c file, you need to add CDT support.
An NDK project is created easily.
Next we will go to the Code section. Let's start with the java section. In your activity, we mainly call your ndk Library and the Library method.
The following is the key part. c. I encountered many errors at that time. Pay special attention to the format and specifications. check the Code directly. be sure to declare your method at the beginning of this extern. Otherwise, an error is returned.
Finally, let's run it. Let's see the effect ..
If there is something wrong with this article, I hope to make a lot of bricks.
This article permanently updates the link address: