Skip to main content

Understanding platform APIs

Android distinguishes between public NDK APIs (stable and supported) and private platform APIs (internal implementation details that may change).
Using private platform APIs can cause your app to break on future Android versions. Only use public NDK APIs in production apps.

Public vs private APIs

Public NDK APIs

Stable
These APIs are officially supported, documented, and guaranteed to remain compatible across Android versions.
Characteristics of public APIs:
  • Documented in the NDK API Reference
  • Headers included in the NDK
  • Linked against public libraries (libandroid.so, liblog.so, etc.)
  • Stability guarantees across Android versions

Private platform APIs

Unstable
Internal Android platform APIs that are not part of the NDK. No compatibility guarantees.
Starting with Android 7.0 (API 24), the platform actively restricts access to private APIs. Restrictions have been strengthened in each release.
Characteristics of private APIs:
  • Not documented for NDK developers
  • May change or be removed without notice
  • May be blocked or restricted at runtime
  • Can cause app crashes or rejections from Google Play

Private API restrictions timeline

Android 7.0 (API 24) - Initial restrictions

Introduced restrictions on accessing private platform symbols:

Android 9.0 (API 28) - Strict enforcement

Android 9.0 introduced strict enforcement of private API restrictions for all apps targeting API 28+.
Restriction categories:

Android 10+ (API 29+) - Progressive restrictions

Each Android version moves more APIs from grey lists to blacklist:

Public API categories

Core Android libraries

These libraries provide public APIs that you can safely link against:
library
Core Android APIs: NativeActivity, Asset Manager, Configuration, etc.
library
Android logging APIs for integration with logcat.
library
Compression library (zlib).
library
EGL graphics initialization and management.
library
OpenGL ES 2.0 graphics API.
library
OpenGL ES 3.0+ graphics API.
library
Vulkan graphics API (API 24+).

Media and audio libraries

library
AAudio high-performance audio API (API 26+).
library
OpenSL ES audio API.
library
Media codec and format APIs (API 21+).
library
Camera2 NDK API (API 24+).

Neural Networks and ML

library
Neural Networks API for hardware-accelerated ML (API 27+).

Library linking examples

CMake configuration

ndk-build configuration

Detecting API availability at runtime

Code example: Runtime API detection

Code example: Weak linking for optional APIs

API availability by category

Graphics APIs

Audio APIs

Camera APIs

ML and compute

Avoiding private API usage

Common mistakes

These patterns indicate private API usage and should be avoided.
Don’t do this:
Do this instead:
Don’t do this:
Do this instead:
Don’t do this:
Do this instead: Use public NDK APIs or JNI to call Java APIs when needed.

Migration strategies

If you’re currently using private APIs, here are migration strategies:

1. Use public NDK equivalents

2. Use JNI to call Java APIs

3. Request new public APIs

If you need functionality that’s not available in the NDK:

File NDK feature request

Request new public APIs through the NDK GitHub repository

Testing for private API usage

Using veridex

Android provides a tool called veridex to detect private API usage:

Lint warnings

Android Studio will show lint warnings for known private API usage:

Official resources

Android changes for NDK developers

Dynamic linker changes and restrictions

Private API restrictions

Official documentation on private API restrictions

Best practices

Stick to APIs documented at developer.android.com/ndk/reference. If an API isn’t documented, assume it’s private.
Private API restrictions vary by Android version. Test your app on API 24, 28, 29, and the latest version.
When using newer APIs, use weak linking to gracefully degrade on older devices.
Subscribe to Android developer announcements to stay informed about API changes and deprecations.

Next steps

NDK API overview

Learn about available NDK APIs and stability guarantees

Dynamic linker

Understanding the Android dynamic linker

Android-specific APIs

Public Android-specific native APIs

Bionic status

C library API availability and POSIX compliance