Search code examples
androidapk

How to reduce the size of apk


My assets and drawable are only 2mb java and xml sources is only 1mb but after build project the apk size is 20mb!

I set shrinkResources true and remove unused resources and generate app with proguard.

Is there a way to reduce the size of apk?


Solution

  • Android Studio has its own apk analyzer which is very useful for cases like yours.

    Analyze your apk file and check which files are using this much space.

    https://developer.android.com/studio/build/apk-analyzer.html

    enter image description here

    Also using ProGuard helps to reduce apk size.

    Additionally, avoid using unnecessary libraries. For example,

    if you need to use Google Analytics, import gradle only analytics library like this:

    compile 'com.google.android.gms:play-services-analytics:10.2.4'
    

    do not use like this:

    compile 'com.google.android.gms:play-services:10.2.4'
    

    second example uses too much space and redundant classes and files.