码迷,mamicode.com
首页 > Windows程序 > 详细

Windows 7 OS,如何Debug NDK Hello-JNI Sample程序

时间:2015-08-03 16:58:54      阅读:416      评论:0      收藏:0      [点我收藏+]

标签:android   ndk   调试   windows 7   eclipse   


  1. 首先,需要明确的是不需要CygWin

  2. ADT中安装NDK插件

    Help | Install New Software …菜单,然后从http://dl-ssl.google.com/android/eclipse/安装AndroidNative Development Tools

    技术分享

     

  3. 然后,Window | Preferences 菜单,确认Android下面有一个NDK选项

    技术分享

  4. C/C++ | Build | Environment下增加一个”NDK_DEBUG”环境变量,并将其值设为1技术分享

  5. Eclipse中,Import进来Hello JNI Sample

  6. 然后,右键单击Hello JNI ProjectAndroid Tools > AddNative Support,然后,接受缺省地Hello-JNI Library

    技术分享

     

  7. 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.

  8. Eclipse中,右键单击Hello JNI ProjectRun | Debug as AndroidApplication。确认程序能运行成功。然后,在模拟器或真机上退出Hello JNI App

  9. 启动一个命令行窗口,进入到Hello JNI目录。然后,运行“ndk-gdb --start--verbose”命令。

  10. 然后, 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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!