How to Make Your APK Smaller
Your app’s APK size has an impactful effect on its load speed, memory usage and power usage. Therefore, it is imperative to make it as small as possible without compromising functionality or performance. There are a few effective methods of shrinking it down including eliminating resources no longer used by your app, using scalable Drawable objects and compressing images; we will explore all these techniques here in this article in order to reduce its size further.
Your APK’s size depends heavily on its contents – including images. To reduce storage space needs and optimize performance, we advise using an image compression tool before including them in your APK. Doing this will drastically decrease their size without impacting quality – saving both storage and performance of the app!
Fonts can also play an essential role. Most apps bundle fonts into their APKs, making the APK much larger than necessary. In order to address this issue, Google recently unveiled Downloadable Fonts; which enables you to directly download fonts from cloud services instead of including them directly in an APK package; thus significantly decreasing its size while simultaneously conserving cellular data and phone memory resources.
Repetitive code is one of the key contributors to an APK’s size. When programming, try to limit repetitive coding as much as possible by employing Object-Oriented Programming or by reusing functions instead of creating new ones. You may also use an app-optimization tool for your app that removes redundant or dead code so as to maintain its size without being hindered by extraneous parts.
Unused language resources are another major contributor to an app’s APK size, taking up space in your APK and slowing it down. To avoid this situation, the Gradle resource shrinker provides a solution by setting its resConfigs property to “no”. This will remove unused languages that take up unnecessary space.
Equally, when creating an APK file for an app that doesn’t need image variants, use scalable vector Drawable objects instead. While including high DPI images takes up valuable space in your APK, they can be reduced significantly through procedural rendering at runtime.
Your APK size can also be reduced by stripping away unnecessary debug libraries. To do this, define builds for both ARM and x86 architectures before stripping any unnecessary debug libraries using AndroidManifest or use Android Studio’s tool to trim unused libraries during development. Furthermore, compress images or reduce audio resolution (or consider changing file formats from wav or wav to ogg or mp3); compress images using built-in compression options in editors such as Photoshop; compress images using online tools – the possibilities are limitless!