Changes between Version 13 and Version 14 of Getting-Started/Android


Ignore:
Timestamp:
Oct 25, 2012 7:57:39 AM (8 years ago)
Author:
nanang
Comment:

Added tutorial for debugging native code.

Legend:

Unmodified
Added
Removed
Modified
  • Getting-Started/Android

    v13 v14  
    4242 
    4343Follow these steps to build apjsua: 
    44  1. Go to apjsua source directory: 
    45     {{{ 
    46 $ cd pjsip-apps/src/apjsua 
    47     }}} 
    48  1. Make sure swig is in the PATH and build the app: 
    49     {{{ 
    50 $ make 
    51     }}} 
     44 1. Make sure SWIG is in the build environment PATH. 
     45     - Alternatively, update SWIG path in {{{$PJDIR/pjsip-apps/src/apjsua/jni/Android.mk}}} file. 
    5246 1. Create Android project from apjsua. In Eclipse: 
    5347    a. From menu: '''File''' --> '''New''' --> '''Project''' 
    5448    a. Select '''Android Project from Existing Code''', press '''Next''' 
    55     a. In ''Root Directory'', put the location of '''apjsua''' source code (i.e. $PJDIR/pjsip-apps/src/apjsua) and press '''Finish''' 
     49    a. In ''Root Directory'', put the location of '''apjsua''' source code (i.e. {{{$PJDIR/pjsip-apps/src/apjsua}}}) and press '''Finish''' 
    5650 1. You may need to select different Android SDK than what is configured in apjsua. You can do this from the project's '''Properties'''. 
    5751 1. You can modify {{{apjsua/res/raw/config.txt}}} for apjsua's config file. 
    5852 1. Run it. 
     53 
     54 
     55== Debugging native code with Eclipse == #debug-native 
     56 
     57Here are the steps for debugging PJSIP native code using Eclipse: 
     58 1. Build PJSIP with debugging enabled, e.g: insert {{{CFLAGS += -g}}} into {{{user.mak}}} in PJSIP root directory. 
     59 1. Make sure that the JNI part of the application is built using {{{ndk-build}}}. For reference, check apjsua's {{{Android.mk}}} build config in {{{pjsip-apps/src/apjsua/jni}}}, it contains sample of how to import PJSIP build settings (build search paths, build flags, etc) and SWIG invocation. 
     60 1. Enable NDK plugin for Eclipse, check [http://tools.android.com/recent/usingthendkplugin this] and follow the instructions. 
     61 1. It is recommended to introduce delay (about 5 seconds) in the application code between loading the native code library and calling any native functions (to be debugged), e.g: 
     62     {{{ 
     63try { 
     64        System.loadLibrary("some_native_lib.so"); 
     65} catch (UnsatisfiedLinkError e) { 
     66        return -1; 
     67} 
     68 
     69// Wait for GDB init 
     70if ((getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) { 
     71        try { 
     72                Thread.sleep(5000); 
     73        } catch (InterruptedException e) { } 
     74} 
     75 
     76// Start calling native functions here 
     77// ... 
     78     }}} 
     79 1. Load PJSIP project to Eclipse, and try put breakpoint anywhere in the PJSIP code before launching the application debug configuration in Eclipse. 
     80 
     81 
    5982 
    6083== Other Android projects ==