Question: Since updating my Android SDK about a month ago I've had endless problems leaving me with a non-functional development environment.

Initially the problem was with the v7-appcompat support library which threw up about 100 errors relating to various resources. It was fairly obvious they were resources relating to Android v5 and a quick search on Stack Overflow meant I realised the v7-appcompat library was targeting API 19. Changing the relevant settings to target API 21 fixed the resource errors.

However, the problem I've had since then is any attempt to build the library project quickly finishes with...

> 
> Error executing aapt: Return code 132
> 
> 
> 

...and the library project isn't built correctly.

My original setup was with Eclipse Kepler but then I tried Android Studio v1.0.1 (same aapt error code) and today I installed Eclipse Luna to a separate directory from Kepler AND a fresh installation of ADT and SDK. Each version of Eclipse also have their own workspaces.

So basically I have two versions of Eclipse (each with their own ADT / SDK setups and workspaces) and Android Studio with its own directory structure and all three exhibit the same problem.

The question is, how do I go about diagnosing this issue? The common denominator is obviously an aapt issue but I have no idea how to fix it.

I'm running on a Debian Wheezy (32-bit) setup and I've got Java 1.7 installed correctly (as recommended).

Answer: 
There seems to be an issue with aapt on some 32 bit systems. It throws an error 132 on app:processDebugResources which is when aapt is 'crunching' png files ready for inclusion in the apk package. You can see more details at <https://code.google.com/p/android/issues/detail?id=75110>

Some people have reported that 'fixing' the offending png files (e.g. by opening in Gimp and saving) sorts the problem. When they are 'built in' to appcompat it's much harder to do of course.

Before getting into detail can you just say if you are indeed running on a 32 bit processor, and if so which one? use lscpu to find out.

OK, if anyone is interested, here is a work around so you can use your old laptop to build apps with Android Studio. Basically you strip all the png files in the appcompat-v7 library and then do a build using two versions of aapt. Yuk.

1. Find the appcompat-v7.aar which will be somewhere like `~/Android/Sdk/extras/android/m2repository/com/android/support/appcompat-v7/22.0.0`
2. Extract it (it's a zip file really) to a temporary directory
3. Strip all the png files: `find . -name "*.png" -exec mogrify -strip {} \;`
4. Pack the files back up again: `pushd appcompat-v7-22.0.0; zip -r ../appcompat-v7-22.0.0.aar; popd`
5. Move the new aar file to replace the original (that may be enough to get a good build but it wasn't for me)
6. Now find an old version of aapt (I went to <https://dl-ssl.google.com/android/repository/build-tools_r17-linux.zip>)
7. Copy the version of aapt from the zip you've just picked up into the Android/Sdk/build-tools directory as aapt-17 or whatever
8. Rename the original aapt to aapt-0
9. Alternate between the two versions of aapt (e.g. `ln -sf aapt-17 aapt`) and you should find you can get a good build. One version will fail in one place, the other in another, getting you past all the bumps.
10. I know it stinks but I was desperate!!
Here's what I did, which is enough to get a successful build. Inspired by peterthevicar's answer.

* downgrade sdk to 19.1.0, you can install it from studio and then change buildToolsVersion in build.gradle
* rename aapt to aapt.bin and put a shell script in its place that intercepts just the png crunch (args: s -i infile -o outfile) and does a simple cp instead. would paste it here but SO's syntax highlighting suuuucks