Build an Android NDK Environment
When using the latest ndk, cygwin is directly discarded. To use NDK for Android projects, you must download NDK and install Cygwin (used to simulate Linux environments ), download the CDT (Eclipse C/C ++ development plug-in) and configure the compiler and environment variables. This is especially troublesome and will not be required for the new version.
Steps:
I,Download the Android Development Tool ADT (abbreviation of Android Development Tool) from the Android official website. The Tool integrates the latest ADT and NDK plug-ins, Eclipse, and the latest SDK version. Decompress the package and use it.
II,ADT Plugin: used to manage the Android SDK and related development tools
NDK plug-in: used to develop Android NDK plug-ins. If the ADT version is later than 20, you can install the NDK plug-in. In addition, the NDK integrates the CDT plug-in.
See: http://developer.android.com/sdk/index.html for download links
3. download the latest NDK from the Android official website. Note: Cygwin is integrated with NDK Versions later than r7 and is still very lite.
See: http://developer.android.com/tools/sdk/ndk/index.html for download links
Eclipse Configuration:
1. Open Eclipse, click Window-> Preferences-> Android-> NDK, set the NDK path, for example, Shamoo is E: \ android-ndk-r9c
2. Create an Android project, right-click Android Tools> Add Native Support... on the project, and name the. so file, for example, my-ndk.
3. At this time, the project will have a jni folder, jni has Android. mk and my-ndk.cpp files. Android. mk is the Makefile of the ndk project, and the my-ndk.cpp is the source file of the NDK.
4. Next, write the Hello-JNI project like the NDK demo. Use Alt + "/'to prompt the code! Great! Do you have? When I used CDT, I was not prompted by the code. I was depressed...
5. the JNI interface naming convention is: Java _ + package name that calls this method (the package name is replaced by _) + _ + class name that calls this interface + _ + method name, two parameters are required for the instance method. a jni environment pointer JNIEnv *
6. Complete and run. Compile the NDK before running it, And then compile the JAVA code. Compilation may encounter Unable to launch cygpath. Is Cygwin on the path? How can this problem be solved? As follows:
7. Right-click the project and click PrZ restart? Http://www.bkjia.com/kf/ware/vc/ "target =" _ blank "class =" keylink "> vcGVydGllcy0 + keys =" http://www.2cto.com/uploadfile/Collfiles/20141101/20141101084240140.jpg "alt =" \ ">
8. Click Environment in C/C ++ Build, and click Add... to Add the Environment variable NDKROOT, the root directory with the value of NDK