android-platform-headers icon indicating copy to clipboard operation
android-platform-headers copied to clipboard

Collection of platform headers and link libs for all versions of Android. (repo is rebased, see wiki)

These are sets of header files extracted from main components of AOSP (Android Open Source Project), for each main release of AOSP.

Android NDK provided by Google contains subset of AOSP platform headers which are deemed "external interface" by Google. However, writing advanced software for Android necessitates access to complete platform. Many aspects of it change, sometimes drastically, between releases, so compiling user source code against platform headers for different releases is required. This project intends to streamline this process, allowing to access headers for all important Android releases at once.

In this respect, it is similar to "linux-kernel-headers" found in many Linux distributions - it allows to compile software without the need to have hundreds of megabytes (or gigabytes) of complete kernel (or platform) source code around.

To prepare these headers, all *.h and *.hpp files were extracted from following AOSP projects:

  • system/core
  • frameworks/base
  • frameworks/native
  • hardware/libhardware
  • hardware/libhardware_legacy

NOTE: Project git repository may undergo rebases. Please rely on tags when using in your projects. Use git pull --rebase for updating your workcopy.

FAQ

Q: Google doesn't recommend usage of non-NDK headers. A: Short answer: who cares. Long answer: Android is a multi-layer system, and there're different rules for different levels. If you want maximum portability, you should not use native code at all, and yet many applications use it to improve performance, etc. Similar logic applies to usage of not officially exported interfaces - sometimes they just need to be used to get most of the underlying system.

Q: As these headers don't represent external interface, they can be changed by a vendor of some device. A: True, so we can figure out what particular vendors work on - bringing up innovative products, cutting time to market, increasing power efficiency, or fragmenting platform and breaking compatibility.

Q: How do I know that headers provided are correct? A: You are encouraged to verify. Each header project directory contains .git-org/refs/heads/master with revision of tag from which it was extracted. Actually, extraction was automatic and script is provided. To easily verify a particular tag:

rm -rf android-1.6_r1
scripts/fetch-headers android-1.6_r1
git diff

TODO

  1. Add platform "import" libraries to link with (devoid of code, only with exported symbols) - in progress.

  2. Similar "implib" jars to link Java code against - in progress.