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
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
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:| List | Description | Behavior |
|---|---|---|
| Whitelist | Public APIs | Always accessible |
| Light grey | Private APIs | Accessible with warning |
| Dark grey | Private APIs | Accessible only if targetSdkVersion < 28 |
| Blacklist | Private APIs | Never accessible |
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:Core Android APIs: NativeActivity, Asset Manager, Configuration, etc.
Android logging APIs for integration with logcat.
Compression library (zlib).
EGL graphics initialization and management.
OpenGL ES 2.0 graphics API.
OpenGL ES 3.0+ graphics API.
Vulkan graphics API (API 24+).
Media and audio libraries
AAudio high-performance audio API (API 26+).
OpenSL ES audio API.
Media codec and format APIs (API 21+).
Camera2 NDK API (API 24+).
Neural Networks and ML
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
| API | Library | Minimum API | Notes |
|---|---|---|---|
| OpenGL ES 2.0 | libGLESv2.so | 21 | Widely supported |
| OpenGL ES 3.0 | libGLESv3.so | 21 | Check device support |
| OpenGL ES 3.1 | libGLESv3.so | 21 | Check device support |
| OpenGL ES 3.2 | libGLESv3.so | 24 | Limited device support |
| Vulkan 1.0 | libvulkan.so | 24 | Check device support |
| Vulkan 1.1 | libvulkan.so | 28 | Check device support |
| EGL 1.4 | libEGL.so | 21 | Required for OpenGL ES |
Audio APIs
| API | Library | Minimum API | Notes |
|---|---|---|---|
| OpenSL ES | libOpenSLES.so | 21 | Legacy, but stable |
| AAudio | libaaudio.so | 26 | Preferred for low latency |
Camera APIs
| API | Library | Minimum API | Notes |
|---|---|---|---|
| Camera2 NDK | libcamera2ndk.so | 24 | Modern camera API |
ML and compute
| API | Library | Minimum API | Notes |
|---|---|---|---|
| NNAPI | libneuralnetworks.so | 27 | Hardware-accelerated ML |
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