Skip to content

Instantly share code, notes, and snippets.

@ksc91u
Last active August 29, 2015 14:06
Show Gist options
  • Save ksc91u/37513796b2cec37bb3c5 to your computer and use it in GitHub Desktop.
Save ksc91u/37513796b2cec37bb3c5 to your computer and use it in GitHub Desktop.
aapt ERROR: 9-patch image malformed
#!/usr/bin/perl
# Fix the following error, using gradle or Android Studio to build some projects with malformed 9 patch image
#
# aapt ERROR: 9-patch image malformed
# Frame pixels must be either solid or transparent (not intermediate alphas).
#
# put the file as sdk/build-tools/20.0.0/aapt and original aapt as aapt.20
# put the file as sdk/build-tools/17.0.0/aapt and original aapt as aapt.17
# force use aapt cruncher by adding:
# android.aaptOptions.useAaptPngCruncher = true
# in your build.gradle
use Cwd 'abs_path';
use Getopt::Long;
use File::Copy;
$argv = join(" ", @ARGV);
@args = @ARGV;
if($argv=~m/\.9\.png/){
$aapt = abs_path($0).".17"; #old aapt does not check 9 patch image
exec($aapt, @args);
}else{
$aapt = abs_path($0).".20";
exec($aapt, @args);
}
@ksc91u
Copy link
Author

ksc91u commented Sep 23, 2014

Might cause error generating AndroidManifest.xml when running on jenkins.

@ksc91u
Copy link
Author

ksc91u commented Sep 26, 2014

Perl too slow, write a bash version

https://gist.github.com/ksc91u/f167a7d56e0c2646c9c8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment