How to reduce and compress an apk file in android

前端 未结 4 644
没有蜡笔的小新
没有蜡笔的小新 2020-12-28 21:06

I have one apk file but its file size is 22.4 MB. It\'s huge, so I need to reduce or compress the apk file in android. What is the right way to reduce and compress the apk f

4条回答
  •  长发绾君心
    2020-12-28 21:45

    Find the problem

    You can Analyse APK from Android Studio. This shows you the various files in their directories and their sizes, both absolute and relative to the whole APK:

    Check for Unused Resources

    This is the easiest: shows you, among others, the unused resources:

    Just remove them from your project.

    Use Vector Images

    Vector Drawables provide one sharp image for all resolutions, greatly reducing the size for your graphics. As usually, you can use these for icons etc, but not for Photos. Non-vectorized images can be reduced with trimage.

    proguard minify

    Add the following to app/build.gradle to enable proguard to reduce unused classes from your project:

    buildTypes {
        release {
          minifyEnabled true
          shrinkResources true
          proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
        }
    }
    

提交回复
热议问题