Reduce apk Size | How to reduce the size of Android apk | Android Breakdown

Android Breakdown
Reduce APK Size

Yes, It is possible

You know what, you can actually reduce the size of apk with following some tips. Giving final touch or making build is not an important thing in most of the companies but they don't notice that it effects on their users. There are different kind of people out side in the world who have different kind of devices with storage and connectivity to the internet. They pay for internet according to use of MBs and GBs on daily,weekly and monthly basis.

So It is really important to save the storage area in devices and speeding up the download speed of your app. Less size means more users and more revenue.
Let's start !!!


1. Compress All Images

Compressing your images of app will give you the major deduction in the size of apk. You can even reduce 50% of it. We know it's not easy to believe but don't worry we will make you to shout loud with happiness. So here is the secret, there are lots of websites to compress images online. We are giving you the name, one of the best website to compress images.

Click here to go tinypng.com

Android Breakdown
Compression of Image

2. Code Shrinking

Do you know about ProGuard ? If not then read this. Now just go to build.gradle file in android studio and add minifyEnabled true. But remember shrinking process of code slows down the time of build. So you should only use it when you are going to release your app or if you are giving it for testing.

Note : Testing should be needed before uploading to google play because shrinking your code can produce unexpected bug due to missing code and files because It only removes the unused code. It doesn't understand precisely about run time changes . for example an activity not used anywhere but added in manifest will be removed by this. And also remember that it doesn't work when Instant Run feature is ON.

android {
    ...
    buildTypes {
        release {
            minifyEnabled true
           
        }
    }



3. Resource Shrinking

Some of you are thinking that what is the difference between code and resource shrinking so don't be confused actually code shrinking is a process to remove unused code. And same as resource shrinking used to remove unused resources. For example if you added libraries including their resources. Shrinking code will remove unused library code and Resource Shrinking will remove unreferenced resources.

NOTE : Resource Shrinking is only works in partnership with Code Shrinking. It Can't remove resources until they are unreferenced by Code Shrinker.

android {
    ...
    buildTypes {
        release {
            shrinkResources true
            minifyEnabled true
        }
    }
}


4. Clean Unused Alternative Resources

Gradle Resource Shrinking is not able to clean alternative resources because it only remove those resources which is unreferenced by code shrinker. But what about others for example app compact and google play services which contains more information then your app needs. Like your app only needs english and hindi language then why other languages is still in you app so to remove them and reduce the size of apk. we have to add resConfigs "en", "hi". You can add more languages separated by comma.

android {
    defaultConfig {
        ...
        resConfigs "en", "hi"
    }
}
That's it for now !!! And don't forget to subscribe us.

Comments