How to reduce APK size in android

APK Size Reduction Technique

Recently we have released an Android application called Correctify. Then, many of the folks started asking us that how this application size can be less than 2.5 MB. Then, I thought to write this article to answer it. There is nothing special, we only have to follow the simple and standard things.

What is Correctify?

Correctify is a free English learning and editing app. It brings the best and powerful machine learning tools to check your text for spelling and grammatical mistakes. You will learn english history and language facts daily through fun facts. This app brings fun in english learning by challenging you with quizzes. Quiz let you test your progress with that of others across the globe though monthly and overall ranking based on the points earned.

Here is the link to the application, you can download and check the functionality. I am sure you will love it.

Apk size reduction technique

So, let’s see, how we can reduce the size of an android application? Following are the things to be considered to reduce the apk size.

  • Use ProGuard: ProGuard will remove the unused Java code. It helps to significantly reduce the code foot prints. Here is the thing to be taken care of, we must test the app properly after applying proguard. We have used the ProGuard in the Correctify.

Refer: Link

  • Use Split APK: This allows you to create the apk for specific density and ABIs. Hence, huge reduction in the apk size.

Refer this link to know how to use split apk to reduce size.

  • Optimize your final APK (after ProGuard) with Facebook’s ReDex. This should reduce the code size as well as potentially improve performance.

Refer: Link , Link, Link

  • Check your layout folder for unnecessary XML files. Use tools like Lint to check resources which are not being used and delete it.

Refer: Link

  • Reduce resources where ever possible. Using shrinkResources attribute in the Gradle will remove all the resources which are not being used anywhere in the project. Enable this in your build.gradle file by adding below line:
release {
...
  shrinkResources true
...
}
  • Remove the localized resources which are not needed by using resConfigs . As all the support libraries may have localized folders for the other languages which we don’t need.
defaultConfig {
...
  resConfigs "en", "hi"
...
}
  • Use Vector Drawables: Using Vector Drawable is one of the best way to reduce the size significantly.

Refer: Link

  • Remove any debug library you have in the app. They can be done by using debugCompile while building testing debug apk. Like we use the library Android Debug Database for debugging database.

Refer: Link

debugCompile 'com.amitshekhar.android:debug-db:1.0.1'
  • Use WebP file format: Instead of using PNG or JPEG files, you can also use the WebP file format for your images, when targeting Android 3.2 (API level 13) and higher. The WebP format provides lossy compression (like JPEG) as well as transparency (like PNG) but can provide better compression than either JPEG or PNG.
  • Use only specific libraries of Google Play Services. Compile only which is required.
  • Use 9-patch image where ever possible.

Refer: Link, Link

Other things that we have used in Correctify are as follows:

  • Android-mvp-architecture: We follow this MVP architecture throughout the application.
  • Fast Android Networking: The overall networking is being done by this library. The only single library for doing everything related to networking. It also supports RxJava.
  • Android Debug Database: This library is used for debugging database.
  • GreenDao: greenDAO is an open source Android ORM making development for SQLite databases easy.
  • Calligraphy: Used for Custom fonts.
  • RxJava: RxJava is a Java VM implementation of Reactive Extensions: A library for composing asynchronous and event-based programs by using observable sequences.
  • We have also created our own Dependency Framework which is very similar to Dagger 2.

Happy Coding 🙂


Also, Let’s become friends on Twitter, Linkedin, Github, and Facebook.


Amit Shekhar

Amit Shekhar

Co-Founder at Mindorks | Learning is a journey, let’s learn together