Reduce apk size android

前端 未结 2 420
旧巷少年郎
旧巷少年郎 2021-01-19 07:59

I am facing a problem with app size in android.

The scenario is,

I developed my android app in Android Studio 2.0 and the size of apk was 23 MB.

Afte

2条回答
  •  北海茫月
    2021-01-19 08:16

    Do this changes in your build.gradle(Module:app) file. It decreases the apk size almost (40-50)%.

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

    It reduces the size of classes.dex files and res folder.

    It is recommended to that you should use webp file format instead of BMP, JPG, PNG for better compression.

    For reference, you can use: https://developer.android.com/studio/write/convert-webp.html

    For more details on apk compression you can refer:

    https://developer.android.com/topic/performance/reduce-apk-size.html

    https://medium.com/how-you-can-decrease-application-size

提交回复
热议问题