Many developers are concerned with the size of their compiled apps. As the APK, app bundle, or IPA version of a Flutter app is self contained, and holds all the code and assets needed to run the app, its size can be a concern. The larger an app, the more space it requires on a device, and the longer it takes to download, and it may break the limit of useful features like Android instant apps.
By default, launching your app with
or by clicking the Play button in your IDE
(as used in Test drive and
Write your first Flutter app),
generates a debug build of the Flutter app.
The app size of a debug build is large due to
the debugging overhead that allows for hot reload
and source level debugging.
To get a better sense of what an end-user actually has to download for a Flutter app, use the following instructions.
Run the following from the top of your Flutter project to get the size of APK for 32-bit Android devices:
flutter build apk --target-platform=android-arm
The output should look something like the following:
Built build/app/outputs/apk/release/app-release.apk (4.2MB).
For 64-bit Android devices, run the following:
flutter build apk --target-platform=android-arm64
Here is an example output:
Built build/app/outputs/apk/release/app-release.apk (4.6MB).
You can run the following to get 2 APKs, one for 32-bit and one for 64-bit:
flutter build apk --split-per-abi
Here’s some sample output:
Built build/app/outputs/apk/release/app-armeabi-v7a-release.apk (4.2MB). Built build/app/outputs/apk/release/app-arm64-v8a-release.apk (4.6MB).
To get a rough idea of how large your release IPA is, run the following:
flutter build ios && tar -zcf build/app.ipa build/ios/iphoneos/Runner.app && ls -lh build/app.ipa
The resulting IPA file for the
(as of this writing) is 8.3 MB.
-rw-r--r-- 1 userName primarygroup 8.3M Oct 25 13:47 build/app.ipa
A closer result can be obtained by creating a release archive as described in the iOS create build archive instructions. If bitcode is enabled on your project, you will also have the option to rebuild from bitcode. This option should be selected if it is available, to more closely match what the App Store will produce for your application. You can also select app thinning for a specific phone architecture, which should be very close to the final IPA size from the store for that device.
To measure an iOS app exactly, you have to upload a release IPA to Apple’s App Store Connect (instructions) and obtain the size report from there. IPAs are commonly larger than APKs as explained in How big is the Flutter engine?, a section in the Flutter FAQ.
Reducing app size
Some of the obvious things you can do to make your app smaller are:
- Remove unused resources
- Minimize resource imported from libraries
- Support a limited number of screen densities
- Compress PNG and JPEG files