Windows 7 OS, how to debug NDK Hello-jni sample Program

Source: Internet
Author: User


  1. first, it needs to be clear that there is no need CygWin .

  2. in the ADT installed in NDK Plugins

    Help | Install New software ... menu, and then from http://dl-ssl.google.com/android/eclipse/ installation androidnative Development Tools .

  3. < P style= "Color:rgb (0,0,0); font-family: ' Calibri ', ' Sans-serif '; font-size:11pt; Font-style:normal; Font-weight:normal; margin-top:0in; Margin-bottom:0pt "> Then, window | Preferences menu, confirm android Below is a option

  4. < P style= "Color:rgb (0,0,0); font-family: ' Calibri ', ' Sans-serif '; font-size:11pt; Font-style:normal; Font-weight:normal; margin-top:0in; Margin-bottom:0pt "> c/c++ | Build | Environment "Ndk_debug" Span lang= "ZH-CN" style= "Font-family:simsun" "Environment variable and set its value to 1

  5. < P style= "Color:rgb (0,0,0); font-family: ' Calibri ', ' Sans-serif '; font-size:11pt; Font-style:normal; Font-weight:normal; margin-top:0in; Margin-bottom:0pt ">eclipse import come in hello JNI Sample

  6. then, right-click Hello JNI Project , Android Tools > addnative Support, then, accept the default Hello-jni Library .

  7. Eclipse will report " Method Newstringutf () could not being resolved "error. Please refer to http://stackoverflow.com/questions/15899813/eclipse-method-newstringutf-could-not-be-resolved to eliminate it.

    go to the project ' s Properties, C + + general Code Analysis.click," 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. < P style= "Color:rgb (0,0,0); font-family: ' Calibri ', ' Sans-serif '; font-size:11pt; Font-style:normal; Font-weight:normal; margin-top:0in; Margin-bottom:0pt "> run | Debug as androidapplication hello JNI App

  9. start a command-line window and go to Hello JNI directory. Then, run the "ndk-gdb--start--verbose" command.

  10. Then , set breakpoints in gdb and run other debug commands

    (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

    *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

    *env->newstringutf (env, "Hello from JNI! ) Compiled with AB

    I "ABI". ");

    (GDB)

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Windows 7 OS, how to debug NDK Hello-jni sample Program

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.