Book Image

Android NDK: Beginner's Guide

By : Sylvain Ratabouil
Book Image

Android NDK: Beginner's Guide

By: Sylvain Ratabouil

Overview of this book

Table of Contents (18 chapters)
Android NDK Beginner's Guide Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Time for action – analyzing a native crash dump


Let's make our application crash to see how to read a crash dump:

  1. Simulate a fatal bug in jni/com_packtpub_store_Store.cpp:

    #include "com_packtpub_store_Store.h"
    
    JNIEXPORT jint JNICALL Java_com_packtpub_store_Store_getCount
      (JNIEnv* pEnv, jobject pObject) {
        pEnv = 0;
        return pEnv->CallIntMethod(0, 0);
    }
  2. Open the LogCat view in Eclipse, select the All Messages (no filter) option, and then run the application. A crash dump appears in the logs. This is not pretty! If you look carefully through it, you should find a backtrace section with a snapshot of the call-stack at the moment the application crashed. However, it does not give the line of code involved:

  3. From a command-line prompt, go to the project directory. Find the line of code implied in the crash by running NDK-Stack with logcat as the input. NDK-Stack needs the obj files corresponding to the device ABI on which the application crashed, for example:

    cd <projet directory&gt...