Debugging an Android NDK application with CheckJNI
JNI does little error checking for better performance.
As a result, errors usually lead to a crash. A mode called CheckJNI
is offered by Android. In this mode, a set of JNI functions with extended checks are called instead of the normal JNI functions. This recipe discusses how to enable the CheckJNI mode to debug Android NDK applications.
How to do it...
The following steps create a sample Android project and enable the CheckJNI
mode:
- Create an Android application named
CheckJNIDemo
. Set the package name ascookbook.chapter3
. Create an activity namedCheckJNIDemoActivity
. Please refer to the Loading native libraries and registering native methods recipe of Chapter 2, Java Native Interface, if you ...
Get Android Native Development Kit Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.