'How to reduce the size of Flutter .aab file?

I made a calculator app using flutter and when I generated the .aab file, it came out to be 16 MB! How do I reduce the size of my .aab file?



Solution 1:[1]

Regarding to the flutter official documentation.

Reducing app size

When building a release version of your app, consider using the --split-debug-info tag. This tag can dramatically reduce code size. For an example of using this tag, see Obfuscating Dart code.

Some other things you can do to make your app smaller are:

  • Remove unused resources
  • Minimize resource imported from libraries
  • Compress PNG and JPEG files

Build the .abb

  1. Clean your project
flutter clean
  1. Build an appbundle using the --split-debug-info tag
 flutter build appbundle --obfuscate  --split-debug-info=<the-path>

Note the <the-path>, a location where your app-release.aab will be copied.


Output

? Building with sound null safety ?

Running Gradle task 'bundleRelease'...                             94,8s
? Built build/app/outputs/bundle/release/app-release.aab (17.5MB).

Note that the final size of my app-release.aab is 17.5MB.


For more details recarding to deploy flutter android app read the official documentation.

Download size

After deploying my Flutter app to playstore, I was surprised to see that the download size is finally 6.4M.

enter image description here

This is a full app in production, not just a default flutter counter app. You can try it on playstore.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1