Sunday, February 10, 2008

Android Eclipse Plugin / AIDL bugs

UPDATE: This work-around is no longer necessary since m5-rc14 fixed the aidl bugs.

The current Android SDK (m3-rc37a) has numerous bugs surrounding the aidl parser, the most annoying of which makes it very difficult to work with a project utilizing aidl imports and the Eclipse Android plugin. In order to ease some frustrations, I have created a wrapper around the aidl tool which tries to guess certain usage parameters and automatically inject the necessary -I switch.

To use the script, enter your Android SDK tools directory and issue the following:

mv aidl aidl.google

Then save the following script as aidl:

#!/usr/bin/perl

my @aidl = split /[\/\\]/, [ grep { /\.aidl$/ } @ARGV ]->[-1];

foreach (reverse @aidl)
{
last if $_ eq 'src';
undef $_;
}

my $I = join('/', map { $_ if $_ } @aidl);

my @args;

push @args, "-I$I" if $I;
push @args, @ARGV;

system("$0.google", @args);

And finally, set the script executable:

chmod +x aidl

No comments: