搞了半天,各种错误,不过结果是好的,终于可以调试native代码了,哈哈~~记录一下。
参考:http://tools.android.com/recent/usingthendkplugin
为了避免上面链接失效,还是把上面链接内容在下面复制一份。
我使用SDK和NDK还有ADT都是Google提供的最新版本的。
Using the NDK plugin
posted Jul 2, 2012 7:16 PM by Siva Velusamy
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.
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
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 Bug 33788. |
用上面的方法配置好后,每次编译都会提示错误:make: *** empty variable name. Stop.
查了n久,只是知道这个错误是ndk不识别路径中‘ ’和‘.’符号,但是各种编译路径都修改后,还是会出现。
最后,终于发现是ndk的命令当中有问题,添加调试标志的时候,NDK_DEBUG=1 等号左右也不能有空格,把空格去掉好了~~~
好了,结局是好的,NDK还是越来越好用了~