What is bionic?
Bionic is Android’s implementation of the C standard library, providing:- Standard C library functions: malloc, printf, file I/O, etc.
- POSIX APIs: Threading, sockets, file operations
- Math library (libm): Mathematical functions
- Dynamic linker: Loads shared libraries at runtime
- Android-specific extensions: Additional APIs for Android platform integration
Bionic is BSD-licensed (not GPL), which aligns with Android’s licensing requirements and allows broader use in proprietary code.
Why bionic exists
Android created bionic instead of using existing C libraries for several reasons:Licensing
Licensing
- BSD license instead of GPL (glibc’s license)
- Allows proprietary code without GPL restrictions
- More flexible for device manufacturers and app developers
Size optimization
Size optimization
- Smaller memory footprint than glibc
- Critical for resource-constrained mobile devices
- Stripped-down implementation focused on Android needs
- Original glibc: ~2-3 MB, bionic: ~500-800 KB
Mobile-specific features
Mobile-specific features
- Optimized for ARM processors (primary Android architecture)
- Fast thread-local storage (TLS)
- Efficient memory allocator for mobile workloads
- Support for Android-specific kernel features
Security
Security
- Built-in FORTIFY_SOURCE protections
- Stack canaries and buffer overflow detection
- Secure random number generation
- Modern security features from the ground up
Key differences from glibc
Understanding these differences helps avoid portability issues:Missing or limited functionality
Bionic intentionally omits some glibc features:- Locale support
- Signal handling
- Threading extensions
- System V IPC
Implementation differences
API levels and compatibility
Bionic evolves with Android versions. Functions are added and behavior changes across API levels:Understanding API levels
- What are API levels?
- Compile-time vs runtime
- Dynamic API checking
Each Android version has an API level:
| Android Version | API Level | Release Year |
|---|---|---|
| Android 15 | 35 | 2024 |
| Android 14 | 34 | 2023 |
| Android 13 | 33 | 2022 |
| Android 12L | 32 | 2022 |
| Android 12 | 31 | 2021 |
| Android 11 | 30 | 2020 |
| Android 10 | 29 | 2019 |
| Android 9 (Pie) | 28 | 2018 |
| Android 8.1 (Oreo) | 27 | 2017 |
| Android 8.0 (Oreo) | 26 | 2017 |
| Android 7.1 (Nougat) | 25 | 2016 |
| Android 7.0 (Nougat) | 24 | 2016 |
| Android 6.0 (Marshmallow) | 23 | 2015 |
| Android 5.1 (Lollipop) | 22 | 2015 |
| Android 5.0 (Lollipop) | 21 | 2014 |
Your app’s
minSdkVersion determines which APIs you can use. Features from higher API levels won’t be available on older devices.Major API level milestones
Key bionic improvements by API level:API 21 (Android 5.0 - Lollipop)
API 21 (Android 5.0 - Lollipop)
Major improvements:
- 64-bit support (arm64-v8a, x86_64)
- Significantly improved locale support via ICU
- Full C11 threading support
- Position-independent executables (PIE) required
API 21 is often considered the minimum for modern NDK development due to 64-bit and improved standards compliance.
API 23 (Android 6.0 - Marshmallow)
API 23 (Android 6.0 - Marshmallow)
Major changes:
- Runtime permissions affect file access
- Better FORTIFY_SOURCE protections
- Enhanced DNS resolution
API 24 (Android 7.0 - Nougat)
API 24 (Android 7.0 - Nougat)
Major changes:
- Private API restrictions begin
- Cannot use non-public symbols from platform libraries
- File-based encryption affects file paths
API 28 (Android 9.0 - Pie)
API 28 (Android 9.0 - Pie)
Major restrictions:
- Strict enforcement of public API access
- Gray-list restrictions on non-SDK interfaces
- Enhanced stack protections
API 29 (Android 10)
API 29 (Android 10)
Features:
- Neural Networks API 1.2
- Scoped storage affects file access
- APEX modularization (bionic can be updated independently)
API 30+ (Android 11+)
API 30+ (Android 11+)
Ongoing improvements:
- Continued security hardening
- New standard library features
- Performance optimizations
- Regular bionic updates via APEX
Standard library support
Bionic supports most C and C++ standards:C standard library
- C99
- C11
- C17/C18
Fully supported (all API levels):
C++ standard library
Bionic works with libc++ (LLVM’s C++ standard library):The NDK uses libc++ (LLVM’s C++ library), not GNU libstdc++. This is important for C++ ABI compatibility.
Common compatibility issues
Using conditionals for API availability
Handling missing functions
Weak linking for optional features
Best practices
Set appropriate minSdkVersion
Recommended minSdkVersion: API 21 (Android 5.0)
- Covers 99%+ of active devices (as of 2024)
- 64-bit support
- Better standards compliance
- Modern security features
Check bionic status documentation
For definitive API availability, consult:Use feature detection
Avoid private APIs
Testing across API levels
Ensure compatibility by testing on multiple Android versions:Resources
For more information on bionic:- Bionic status documentation - API availability by version
- Changes for NDK developers - Important changes across versions
- 32-bit ABI bugs - Known issues in 32-bit code
- NDK API Reference - Official API documentation
Next steps
- Explore build systems for compiling with specific API levels
- Review native development best practices
- Understand JNI for Java/native interaction
When in doubt about API availability, compile with the lowest minSdkVersion you support and test on actual devices running that Android version.