Upworthy title aside, apps have gotten quite bloated lately, with higher resolution assets and numerous libraries that ease development but also contribute, sometimes significantly, to APK size. Cyril Mottier wrote a great article about reducing the size of android apps: Putting Your APKs On Diet. The post describes general common sense things, like, don’t include resources you aren’t using, as well as more advanced things like using ProGuard to obfuscate and minify code.

I put one of my apps, Soup, on the Cyril APK Diet, here are the results:

Starting Weight (Size): 5.10 MB

####1. Remove Unused/Old Res Folders Easy - Quick
I removed both ldpi/mdpi folders. Specified resConfigs for languages that I support (en, es, fr, pt, ru) which got rid of 50+ unwanted language resources from Google Play Services, among other dependencies. This is non-destructive, when I am ready to support more languages, I just add them to that list and, voila, they are included (when available) from the imported libraries.
APK Size: 4.40 MB - 13% Total Reduction

####2. Android lint Easy - Time-consuming
I ran lint, using gradlew lint from the terminal, then removed unused drawables/layouts/menus and other resource files that lint discovered.
APK Size: 4.19 MB - 17.8% Total Reduction

Note: You have to be careful here, if you are referencing a drawable in code, lint doesn’t necessarily see that, so you should, as Cyril points out, “Know your code like the back of one’s hand.”

####3. Minify PNGs Medium - Fairly quick
I minified PNGs using PNGoo, there are loads of tools on that page for all platforms, GUI and command line.
APK Size: 4.16 MB - 18.4% Total Reduction

####4. ProGuard Difficult - Very Time-consuming
This took the longest, the first attempt to run threw a whole bunch of warnings, I cleaned up redundant dependencies from included libraries. This is really easy to enable just add the following to your app’s build.gradle.

Open build.gradle in Gist

Done, right?

Nope, then you need to create a proguard-rules.txt file, if it doesn’t already exist. This file allows you to specify how ProGuard behaves when it attempts to remove unused code, and optimize it. Depending on your included libraries, this may or may not be a simple task.

After a few hours of searching Google, StackOverflow and GitHub I gave up. I was able to remove some proguard warnings using a few helper libraries, but got stuck on Dagger, like many, many, others. I could get some warnings to go away, but then another error popped up elsewhere. I don’t know how much space I would save if I could actually get ProGuard to run. I’ll take another look at it when Dagger 2 is released, it should remove some of the problems I and others encountered.
APK Size: Unknown

Final App Size: 4.16MB
Total savings: 18.4%

####Conclusion You should definitely attempt to clean up any code/resources that you aren’t using in your apps. I saved ~1MB, doesn’t seem like much, but considering the relatively small effort (excluding ProGuard) that it required, well worth it. Maybe you will have better luck with ProGuard than I did. Happy dieting.