When i run my app size of apk will 21 MB. even i enabled proguard. i use android studio to run project. in project files src folder has 8.62 MB size and lib folder size is 4
There are a few techniques you can use to reduce the apk size:
1. Proguard: In build.gradle file for app-level, add the following code
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
2. Unnecessary Resources: Many times unnecessary resources are present in the source code. Inpect the source code by Analyze->Inspect Code. After the inspection ends, delete unnecessary resources.
3. Webp images: Webp images have less size than png files and also it retains the original image quality. More to that webp images are natively supported in Android. Right-click the drawable(/mipmap) folder -> Convert to webp. Choose appropriate options which suits your need.
4. Signed apk: The debug apk size is greater than the signed apk. Generate signed apk by going to Build-> Generate Signed Bundle/Apk->APK. Overall apk size is now reduced.
5. Android App Bundle: If you are going to upload the app on Google Play, generate Android App bundle instead of apk.To generate app bundle go to, Build-> Generate Signed Bundle/Apk-> Android App Bundle. It will reduce your app size for sure. For example, my apk size of 10 MB is reduced to just 6-7 MB using Android App Bundle.