First of all, don't suggest me official documentation or this. When we build an app from Android Studio with predefined textview that simply displays "hello world", it generates an APK with more than 1.2MB. But some apps on playstore is available under 500KB with lot of features. I already applied all features of Android Studio like proguard, minifyEnabled etc. but that does not help. So, how can i achieve that level of compression?
You can compress an APK file (rar, zip), but it has to be decompressed in order to work. ProGuard is a free Java class file shrinker, optimizer, obfuscator, and preverifier. It detects and removes unused classes, fields, methods, and attributes. It optimizes bytecode and removes unused instructions.
Average Android and iOS file size Of all mobile apps published on the app stores, the average Android app file size is 11.5MB. And the average iOS app file size is 34.3MB.
When create new project from Android studio, the IDE automatically add some dependencies to your project.
dependencies {
// ...
implementation fileTree(dir: 'libs', include: ['*.jar'])
// implementation 'com.android.support:appcompat-v7:26.1.0'
// implementation 'com.android.support.constraint:constraint-layout:1.0.2'
// ...
}
If you bundle support library
and constraint layout library
, your release apk size will increase rapidly even you don't add any code.
You can get a very small apk if you remove support library and constraint layout library and just use all the system api.
After remove the support library, you should
use Activity
rather than AppCompatActivity
, YourActivity extends Activity
do not use any theme from support library in your AndroidManifest.xml
use FrameLayout
to replace ConstraintLayout
in your layout
Points to reduce APK size:
1. Use vector drawable
2. Use xml drawable to create simple view
3. Rotate images using xml drawable to reuse (eg. in case of arrow buttons)
4. Create drawable through code
5. Use aaptOptions { cruncherEnabled = false } to compress images
6. Use webP format for large images
7. Avoid enumerations and use @IntDef annotation
8. Use shrinkResources true in gradle to remove unused resources
9. Use resConfig “en” in gradle to remove other localization
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With