Debugging NDK

Debugging source code developed with NDK is not as straightforward as debugging code that has been developed with the standard Android Java DK, but there are tools available for this platform. Android Studio provides, since version 1.3, some built-in tools to debug applications with JNI.

In order to prepare an application to be debugged, we need to modify our build.gradle script. As an example, take the HelloWorldJNI we have written previously. Open the build.gradle file of the app module and add the following lines:

buildTypes {
        release {
            minifyEnabled false
            {…}
            ndk {
                debuggable = true
            }

        }
        debug {
            debuggable = true
            jniDebuggable = true
        }
    }

A new configuration for debugging needs to be created. In order to achieve it, navigate to

Get Android High Performance Programming 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.