---
title: "Android Native Development Kit (NDK)"
description: "Learn how to configure the NDK integration."
url: https://docs.sentry.io/platforms/android/configuration/using-ndk/
---

# Android Native Development Kit (NDK) | Sentry for Android

The Android Native Development Kit (NDK) allows you to implement parts of your app in native code, using languages such as C and C++.

NDK integration is packed with the SDK. The package `sentry-android-ndk` works by bundling Sentry's native SDK, [`sentry-native`](https://docs.sentry.io/platforms/native.md). As a result, even if a native library in your app causes the crash, Sentry is able to capture it.

You can [disable the NDK integration](https://docs.sentry.io/platforms/android/configuration/using-ndk.md#disable-ndk-integration), or use our Sentry Android SDK [without the NDK](https://docs.sentry.io/platforms/android/configuration/using-ndk.md#using-the-sdk-without-the-ndk).

Starting with Sentry Android SDK version 8.32.0 you can enable the [Tombstone Integration](https://docs.sentry.io/platforms/android/configuration/tombstones.md) as a replacement or extension to the NDK integration.

## [Symbolicate Stack Traces](https://docs.sentry.io/platforms/android/configuration/using-ndk.md#symbolicate-stack-traces)

To symbolicate the stack trace from native code, we need to have access to the debug symbols of your application.

Use the [Sentry Android Gradle Plugin](https://docs.sentry.io/platforms/android/configuration/gradle.md) to upload the debug symbols and sources automatically.

Alternatively, in case you're not using Gradle, you can upload your `.so` files manually via `sentry-cli`. Please check the full documentation on [uploading files](https://docs.sentry.io/platforms/android/data-management/debug-files/upload.md) to learn more about the upload of the debug symbols.

## [Allowing the Compiler to Link Libraries](https://docs.sentry.io/platforms/android/configuration/using-ndk.md#allowing-the-compiler-to-link-libraries)

To use the Android NDK in your native code, include the `sentry-native` NDK libraries so the compiler can link them during the build. Use Android prefab to consume Sentry's prebuilt packages and link them in your `CMakeLists.txt`.

Android prefab support can only be used with Sentry Android SDK version 8.0.0 and above.

Enable prefab and add the sentry-native ndk dependency directly to your module:

`app/build.gradle`

```kotlin
android {
    buildFeatures {
        prefab = true
    }
}

dependencies {
    // The version MUST match with the version the Sentry Android SDK is using.
    // See https://github.com/getsentry/sentry-java/blob/8.38.0/gradle/libs.versions.toml
    implementation("io.sentry:sentry-native-ndk:<version>")
}
```

Link the pre-built packages with your native code

`app/CMakeLists.txt`

```text
find_package(sentry-native-ndk REQUIRED CONFIG)

target_link_libraries(<app> PRIVATE
    sentry-native-ndk::sentry-android
    sentry-native-ndk::sentry
)
```

Now you can use the Sentry NDK API just by including the `sentry.h` in your code:

```c
#include <jni.h>
#include <android/log.h>
#include <sentry.h>

#define TAG "sentry-android-demo"
extern "C" JNIEXPORT jstring JNICALL

Java_io_sentry_demo_NativeDemo_crash(JNIEnv *env, jclass cls) {
    __android_log_print(ANDROID_LOG_WARN, "", "Capture a message.");
    sentry_value_t event = sentry_value_new_message_event(
            /*   level */ SENTRY_LEVEL_INFO,
            /*  logger */ "custom",
            /* message */ "Sample message!"
    );
    sentry_capture_event(event);
}
```

## [Disable NDK Integration](https://docs.sentry.io/platforms/android/configuration/using-ndk.md#disable-ndk-integration)

You can disable the NDK integration by adding the following to your `AndroidManifest.xml`:

`AndroidManifest.xml`

```xml
<application>
    <meta-data android:name="io.sentry.ndk.enable" android:value="false" />
</application>
```

## [Using the SDK without the NDK](https://docs.sentry.io/platforms/android/configuration/using-ndk.md#using-the-sdk-without-the-ndk)

You can use Sentry's Android SDK without the Android Native Development Kit (NDK) by either:

* [Disabling the NDK](https://docs.sentry.io/platforms/android/configuration/using-ndk.md#disable-ndk-integration)
* Using `sentry-android-core`, which doesn't contain the NDK and can be used separately instead of `sentry-android`, when adding the dependency. The minimal required API level for `sentry-android-core` is 14.

If you're using our [Gradle plugin](https://docs.sentry.io/platforms/android/configuration/gradle.md), it'll still pull the NDK integration in as part of the auto-installation feature. To disable it, remove the `sentry-android-ndk` dependency from the app configurations in `app/build.gradle`:

```groovy
configurations.configureEach {
  exclude group: "io.sentry", module: "sentry-android-ndk"
}
```

## [Troubleshooting](https://docs.sentry.io/platforms/android/configuration/using-ndk.md#troubleshooting)

### [Missing Debug Images or Unsymbolicated Stack Traces](https://docs.sentry.io/platforms/android/configuration/using-ndk.md#missing-debug-images-or-unsymbolicated-stack-traces)

Unsymbolicated stack traces may be caused by module-caching on the SDK side. Be sure to clear any existing module cache if your modules are loaded dynamically:

```cpp
// 1. Load a new module
load_my_module();

// 2. Clear the module cache
sentry_clear_modulecache();
```
