In my Android Package Size post, I described how to retrieve the size of an android package. It requires the use of AIDL, which is Android’s IDL for interprocess communication (IPC).

Using Eclipse and ADT, working with AIDL files is very simple: When AIDL files are created or imported into the src/ folder, the ADT plugin automatically generates the interface definitions and stubs in the gen/ directory as part of the build.

For example, to generate the IPackageStatsObserver interface and stub for the code used in Android Package Size:

  1. Download the AIDL files for PackageStats and IPackageStatsObserver
  2. Create a new java package android.content.pm
  3. Copy or import both AIDL files to the new package
  4. The ADT plugin will generate the IPackageStatsObserver interface and stub automatically in gen/

The Android SDK also includes a (command line) compiler aidl (in the tools/ directory) that you can use to generate the java code in case you don’t use Eclipse.