Using AIDL with Eclipse and ADT
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:
- Download the AIDL files for
PackageStats
andIPackageStatsObserver
- Create a new java package
android.content.pm
- Copy or import both AIDL files to the new package
- The ADT plugin will generate the
IPackageStatsObserver
interface and stub automatically ingen/
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.