Install NDK in Eclipse/Android Studio

Install NDK in Eclipse/Android Studio

  1、 Download NDK

  2、Install NDK

$ tar xvf android-ndk-r8e-linux-x86_64.tar.bz2 -C ~/Software/Android/
$ cd Android
$ mv android-ndk-r8e/ ndk/

  3、add PATH

$ vim ~/.bashrc
//----------------- add the following text ----------------------
export NDK_HOME=/home/linx/Software/Android/ndk
$ source ~/.bashrc

  4、test the ndk

$ pwd

$ ndk-build
Compile++ thumb  : gl2jni <= gl_code.cpp
StaticLibrary  : libstdc++.a
SharedLibrary  :
Install        : => libs/armeabi/    

  the object file is "libs/armeabi/"

  the ndk install success.

  then add the ndk to IDE.


  Eclipse :

  1、download CDT

  1) offline

  2) online

Help -> Install New Software

  add the URL

  then the CDT install automatic.

  2、run ndk-build in the project exist

$ pwd

$ ndk-build

  3、Import the project first

File -> New -> Project.. -> Android Project from Existing Code

  browse form the project root directory.

  4、config the NDK in IDE

  1) File -> Properties

  2) builders -> New -> Program -> OK

  3)in Edit Configuration

Name : hellojni (the project you want to build)

  Table Main :

Location :
Working Directory :
Arguments :
-c "cd ~/Software/Android/ndk/samples/hello-jni/ && ndk-build"

  Table Refresh :

click on "Refresh resources upon completion."

then choose the "Specific resources"

finally choose the "libs" in "Specific resources" and Finish it 

  Table Build Options :

click on everything in "Run in builder"

then choose the "Specify Resources"

finally choose the "jni"  in "Specify Resources"