Understanding platform APIs
Android distinguishes between public NDK APIs (stable and supported) and private platform APIs (internal implementation details that may change).Public vs private APIs
Public NDK APIs
Stable
These APIs are officially supported, documented, and guaranteed to remain compatible across Android versions.
- 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.
- 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
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
Linking against private libraries
Linking against private libraries
Don’t do this:Do this instead:
Using internal headers
Using internal headers
Don’t do this:Do this instead:
Accessing symbols via dlopen/dlsym
Accessing symbols via dlopen/dlsym
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 calledveridex 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
Only use documented NDK APIs
Only use documented NDK APIs
Stick to APIs documented at developer.android.com/ndk/reference. If an API isn’t documented, assume it’s private.
Test on multiple Android versions
Test on multiple Android versions
Private API restrictions vary by Android version. Test your app on API 24, 28, 29, and the latest version.
Use weak linking for optional features
Use weak linking for optional features
When using newer APIs, use weak linking to gracefully degrade on older devices.
Monitor Android platform changes
Monitor Android platform changes
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