Eclipse需要装CDT且版本必须为: CDT 7.0.2 or CDT 8.0.2.


主要实现功能:

1.设置NDK环境

Eclipse -> Window -> Preferences -> Android -> NDK -> 设置NDK路径

在Android工程右键菜单选择Android Tools -> Add native support.

2.

调试NDK代码

在Android工程右键菜单选择-> properties -> C/C++ Build:2. 在C代码打断点。
3.在Android工程右键菜单选择 Debug As -> Android Native Application


下面为英文原文,有兴趣可读读。


ADT 20 includes an NDK plugin that provides support for building and debugging NDK projects in Eclipse. This document describes how to install and use the NDK plugin.


Installation
The NDK plugin currently works with CDT 7.0.2 or CDT 8.0.2.
  1. Download Eclipse for Java.
  2. Install CDT from Eclipse update site http://download.eclipse.org/tools/cdt/releases/indigo.
  3. Install Android SDK + NDK Plugins from Eclipse update site https://dl-ssl.google.com/android/eclipse/
Using the NDK Plugin

1. First set the path to SDK and NDK:

Eclipse -> Window -> Preferences -> Android -> set path to SDK

Eclipse -> Window -> Preferences -> Android -> NDK -> set path to the NDK


2. Right click on an Android project and select Android Tools -> Add native support.
Note that you will not be able to add native support if the project already has C/C++ nature.

At this point, you will be able to build your applications using Project -> Build All.

Debugging native applications

1. Update your build config to include “NDK_DEBUG = 1”.

Right click project -> properties -> C/C++ Build:

2. Set a breakpoint in your C code.
3. Right click on your project, select Debug As -> Android Native Application

Note: There is a delay of a few seconds between when the activity is launched and when native debugging starts. If your code is already executed by that point, then you won’t see the breakpoint being hit. So either put a breakpoint in code that is called repetitively, or make sure that you call JNI code after you see that ndk-gdb has connected.

Known Issues

1. Eclipse does not automatically find the include paths to all the NDK headers on Windows. This issue will be fixed in the next update (20.0.1) when it is released.
2. Eclipse does not automatically find the include paths with CDT 8.1.0 (Juno). This issue is tracked in Bug33788.

更多相关文章

  1. 9.5android线程优先级,go和rust比较
  2. Android(安卓)WebView 缓存处理
  3. Android之ExpandableListView的属性(Group不展开)
  4. Android笔记2——开发前奏2工程目录介绍和两个小应用
  5. Android(安卓)OpenGL ES 简明开发教程二:构造OpenGL ES View
  6. Android中显示gif动画
  7. Android进度条——ProgressDialog
  8. Android(安卓)GradientDrawable类的详解,设置activity的背景颜色
  9. Android(安卓)WebView属性及用法

随机推荐

  1. Android(安卓)围绕中心旋转一个ImageView
  2. android 天气预报 界面
  3. Android文件简单读写操作
  4. 你追我赶进度条
  5. android 图片拖动简单例子
  6. Android(安卓)add external jar
  7. android修改默认桌面
  8. Android(安卓)开机启动程序
  9. Android(安卓)通知提示功能
  10. Android(安卓)UI界面之TableLayout