标签:android ndk 调试 windows 7 eclipse
首先,需要明确的是不需要CygWin。
在ADT中安装NDK插件
Help | Install New Software …菜单,然后从http://dl-ssl.google.com/android/eclipse/安装AndroidNative Development Tools。
然后,Window | Preferences 菜单,确认Android下面有一个NDK选项
在C/C++ | Build | Environment下增加一个”NDK_DEBUG”环境变量,并将其值设为1
Eclipse中,Import进来Hello JNI Sample
然后,右键单击Hello JNI Project,Android Tools > AddNative Support,然后,接受缺省地Hello-JNI Library。
Eclipse会报“Method NewStringUTF()could not be resolved”错误。请参考http://stackoverflow.com/questions/15899813/eclipse-method-newstringutf-could-not-be-resolved以消除它。
Go to the project‘s Properties -> C/C++ General -> Code Analysis.Click the "Use project settings" radio button (or "ConfigureWorkspace Settings..." button). Disable (uncheck) the "Method cannotbe resolved" checkbox. Click "Apply," "OK." Then foryour project, refresh, clean, refresh, build.
在Eclipse中,右键单击Hello JNI Project,Run | Debug as AndroidApplication。确认程序能运行成功。然后,在模拟器或真机上退出Hello JNI App。
启动一个命令行窗口,进入到Hello JNI目录。然后,运行“ndk-gdb --start--verbose”命令。
然后, 在 gdb中设置断点,并运行其它调试命令
(gdb) b hello-jni.c:62
No symbol table is loaded. Use the "file" command.
Breakpoint 1 (hello-jni.c:62)pending.
(gdb) c
Continuing.
Exception in thread Thread-3:
Traceback (most recent calllast):
File "C:\Python34\lib\threading.py", line 920, in_bootstrap_inner
self.run()
File "C:\Python34\lib\threading.py", line 868, in run
self._target(*self._args, **self._kwargs)
File"C:\Users\Qingxu_Li\AppData\Local\Android\android-ndk-r10d\ndk-gdb.py",l
ine 353, in async_stderr
output_fn(line.replace(‘\r‘,‘‘).replace(‘\n‘, ‘‘))
TypeError: expected bytes,bytearray or buffer compatible object
Breakpoint 1,Java_com_example_hellojni_HelloJni_stringFromJNI (
env=0x41c77e00, thiz=0xd2e00019) atjni/hello-jni.c:62
62 return (*env)->NewStringUTF(env,"Hello from JNI ! Compiled with AB
I " ABI ".");
(gdb) bt
#0 Java_com_example_hellojni_HelloJni_stringFromJNI (env=0x41c77e00,
thiz=0xd2e00019) at jni/hello-jni.c:62
#1 0x40b81550 in ?? ()
#2 0x40b81550 in ?? ()
Backtrace stopped: previousframe identical to this frame (corrupt stack?)
(gdb) frame
#0 Java_com_example_hellojni_HelloJni_stringFromJNI (env=0x41c77e00,
thiz=0xd2e00019) at jni/hello-jni.c:62
62 return (*env)->NewStringUTF(env,"Hello from JNI ! Compiled with AB
I " ABI ".");
(gdb)
版权声明:本文为博主原创文章,未经博主允许不得转载。
Windows 7 OS,如何Debug NDK Hello-JNI Sample程序
标签:android ndk 调试 windows 7 eclipse
原文地址:http://blog.csdn.net/liqingxu2005/article/details/47257461