转自:http://www.cnblogs.com/plinx/p/3143461.html

  1、 Download NDK

https://developer.android.com/tools/sdk/ndk/index.html

  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/ndkexport PATH=${NDK_HOME}:$PATH//------------------------------------------------------------------------$ source ~/.bashrc
复制代码

  4、test the ndk

复制代码
$ pwd~/Software/Android/ndk/samples/hello-gl2$ ndk-buildCompile++ thumb  : gl2jni <= gl_code.cppStaticLibrary  : libstdc++.aSharedLibrary  : libgl2jni.soInstall        : libgl2jni.so => libs/armeabi/libgl2jni.so    
复制代码

  the object file is "libs/armeabi/libgl2jni.so"

  the ndk install success.

  then add the ndk to IDE.

Install NDK in Eclipse/Android Studio

  Eclipse :

  1、download CDT

  1) offline

http://www.eclipse.org/cdt/downloads.php

  2) online

Help -> Install New Software

  add the URL

http://download.eclipse.org/tools/cdt/releases/juno/

  then the CDT install automatic.

  2、run ndk-build in the project exist

$ pwd~/Software/Android/ndk/samples/hello-jni$ 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 :/bin/bashWorking Directory :/binArguments :-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"

  Finish.

  Android Studio :

  ok, there is a FAQ answered this question:

Is it planned to support NDK development in Android Studio or IntelliJ IDEA?We have recently announced that we’re starting work on an IDE for C++, and we plan to eventually support NDK development as part of that effort. As for NDK development support in Android Studio, Google hasn’t announced anything so far.

  so just run ndk-build in terminal.

更多相关文章

  1. Android Media Recorder录音播放源代码
  2. android实现自动关机代码
  3. Android 用源代码写layout布局
  4. 记录代码合并时产生的bug
  5. Android常用功能代码块
  6. Android拍照上传代码样例
  7. android打开联系人的代码
  8. Android 监听WiFi的开关状态实现代码

随机推荐

  1. 选择jquery - 列表未以模态形式加载
  2. Jquery UI draggable不会调整其他DIV的大
  3. prototype.Function没有在node.js中导出
  4. JavaScript:使用函数参数检索javascript对
  5. 入职必备技能(三)HTML、CSS、JAVASCRIPT
  6. Javascript 排序算法(转)
  7. AngularJS我在哪里可以访问加载的控制器
  8. 动画在画布中移动图像
  9. 掌握JavaScript中的事件监听
  10. JavaScript中的对象描述符