Tag: proguard

42MB to display account information?! Use the Android APK Analyzer to reduce your APK size!

42MB to display account information?! Use the Android APK Analyzer to reduce your APK size!

After looking around at a few Android applications, I realised that there are many developers who don’t know about a great tool in Android Studio — the Android APK Analyzer. I cringe when I go to download a basic application (most of these apps are really simple) and the download size is over 40MB. Whenever I see this, if I have a bit of time, I like to dive into looking at what is bloating the APK.

Looking into these different APKs, I’ve come across some interesting files, from test data to iOS image files, I’ve seen it all. Whilst analyzing these APK files, I’ve noticed some common trends/mistakes that developers make.

I took a look at some of the Top(*) South African Android apps from the Google Play Store and found some interesting information. This blog post aims to show you how easy it is to look into your app and see what the biggest culprit of eating data in your app is. [Disclaimer: I’m not displaying which apps did what — you can figure that out yourself (reach me on Twitter if you want me to help you lower your APK size). ]

The average download size of the Top(*) South African Android app is ~15.3MB — with the largest size sitting at ~ 42MB. 

The largest app on the store had 18.8MB of images and 14MB of native libraries packaged inside.

Okay, so I’ve hopefully gotten your attention. We know our apps are too big, but how do we go about finding this information and improving our apps?

Read More Read More

Android – Reduce the size of your APK files

Android – Reduce the size of your APK files

If it is one thing that I hate – it is apps that are HUGE downloads for really simplistic functionality.

40MB for an app that just accesses some messages and has hardly any images, what is it doing??

313

I have recently had quite an obsession trying to reduce my app size and have managed to shave off 6MB with a few optimisations (Yay right?!!!! 😃). I thought I would share some tips on how to reduce your Android APK file size:

  1. Use ProGuard: this will obfuscate your code and reduce the app size. [1]
  2. Enable the following with gradle:
    • minifyEnabled – this will get rid of unused code.
    • shrinkResources – this will get rid of unused resources such as layouts or strings that are not referenced in your app.
  3. Make use of split APKs. This is especially useful if you are using native libraries. The native libraries can be quite large and making a user download an x86 library when their device is ARMv7 is pointless. Strip that out. [2]
  4. Check your images. If there are any large bitmaps, chances are you can reduce the size without losing much detail in the image. If possible, use JPEGs instead of PNGs as they are generally smaller.[3]
  5. Consider using Vector Drawables instead of PNGs for every density bucket. This will reduce the number of files needed and the images won’t degrade in quality.[4]
  6. Don’t use images if you don’t need to. Gradient backgrounds, shapes or colours can be achieved with XML instead.[5]
  7. Consider the libraries you use. If a library is massive and you are only using one or two functions you should find an alternative smaller option. Look through your code to see if there are any unused JAR files or unused code and remove that too.

Be careful when doing the things listed above, make sure you test thoroughly after applying these changes as it could break parts of your app. It could get rid of resources or code that might be used.

What do you do to reduce the size of your APKs?

Links:
  1. ProGuard Documentation
  2. Split APKs
  3. PNG vs JPG vs SVG
  4. Vector Asset Studio
  5. Drawable Resources