Does the flutter apk size really matter?

Nithesh
5 min readAug 30, 2020

--

Being held up in the deary lockdown, as all other days I woke up to an other dull day. Suddenly a flash of positivity popped out in my mind, urging me to learn something new. After running a short research on what to learn I ended up with Flutter. Flutter inspired me the most by its appealing features and performance.

Google has been secretly developing Fuchsia OS that supports the software created by flutter. If fuchsia strikes a hit in the market, then flutter would be at the hands of most of the developers. If it goes the other way around, yet flutter can be deployed in developing applications for other platforms such as android, ios, web, Linux(snap store), and macOS.

I enjoyed the brisky me after a long time. With all my laptop and chargers set, I started off with a course offered by Angela Yu in udemy. When I was drawing towards the end I noticed that the size of the flutter apk was quite large. I was puzzled for a moment. And then a pretty much googling made me know that only in debug mode the size of flutter apk is more, which is not an issue.

In debug mode, the app is set up for debugging on the physical device, emulator, or simulator.

Debug mode for mobile apps involves,

  • Enabling assertions.
  • Enabling service extensions.
  • Optimizing the compilation for fast development and run cycles (but not for execution speed, binary size, or deployment).
  • Debugging and tools supporting source-level debugging (such as DevTools) can connect to the process.

Flutter’s hot reload feature which is accessible only in debug mode helps you quickly and easily experiment, build UIs, add features, and fix bugs

Flutter application — debug mode

(tom app is the sample application that is developed for the proof of concept)

There is a build mode namely release mode which gets the actual size of the apk.

Use release mode for deploying the app, when you want maximum optimization and minimal footprint size. For mobile, release mode (which is not supported on the simulator or emulator), involves:

  • Disabling assertions.
  • Stripping out the debugging of information.
  • Disabling the debugging.
  • Optimizing the compilation for fast startup, fast execution, and small package sizes.
  • Disabling service extensions.
Flutter application — Release mode

You all might be still wondering that the size of the flutter application is still more for this simple application. But the alluring factor is that it applies to all the native and hybrid applications. The apk size of the application is not the same as the storage occupied by the same application after installation.

Android apps have an extension “APK” which stands for Android Application Package. This is similar to the zip file. It contains all the application related components clubbed together. You can even open it using a zip manager to see the files inside it. When this gets installed, all the components are extracted. Hence, the size increases after extraction.

So, yes. You were slightly right. The app in APK form can be understood as to be in the “compressed” form.

Now, the reason the size increases even more after transferring to SD card is that, while all these extracted files are transferred to SD card, some of the files need to be in internal/phone memory to act as a link between the phone and app. (The reason why you can change SD card, and get the app back when reinsert that SD card). This leads to an increase in size.

So the actual size of the APK generated for this application is 5.7 MB. After installation, it is 17.59 MB.

Size of flutter tom app apk

Application with the same layout in native android cost with the size of 1.43 MB.

Native android application

The flutter team also acknowledges it.

In July 2019, we measured the download size of a minimal Flutter app (no Material Components, just a single Center widget, built with flutter build apk — split-per-abi), bundled and compressed as a release APK, to be approximately 4.3 MB for ARM, and 4.6 MB for ARM 64.

In ARM, the core engine is approximately 3.2 MB (compressed), the framework + app code is approximately 920.6 KB (compressed), the LICENSE file is 54.3 KB (compressed), necessary Java code (classes.dex) is 113.6 KB (compressed).

In ARM64, the core engine is approximately 3.5 MB (compressed), the framework + app code is approximately 872 KB (compressed), the LICENSE file is 54.3 KB (compressed), necessary Java code (classes.dex) is 113.6 KB (compressed).

These numbers were measured using apk analyzer, which is also built into Android Studio.

Also, the relative differences in apk size would likely be smaller with larger apps. Flutter’s overhead size is fixed.

Flutter team has been buckling down to reduce the size of APK. Check out Comparing APK sizes to view the apk sizes from java, kotlin, react native, and flutter (don’t miss the update message). In 2018 the minimal apk size is 6.7 MB and now it is approximately 4.3 MB for ARM, and 4.6 MB for ARM 64.

React Native works by relying on a given system’s native UI components, also known as OEM widgets, or original equipment manufacturer widgets. React Native is developed in such a way that we can create a bridge between the Native Language and the JavaScript code. But

Flutter is different from most other options for building mobile apps because Flutter uses neither WebView nor the OEM widgets that shipped with the device. Instead, Flutter uses its own high-performance rendering engine to draw widgets.

Isn’t it astounding?

Flutter would be a double-edged sword, having innumerous benefits and also a snag of huge size. The size might be a concern only when it is compared with native android. Flutter perks us up by building expressive and beautiful UI’s, which is Fuchsia’s UI rendering engine. It also supports RIVE, a powerful design, and animation tool.

Quality, and not quantity! Flutter does it rightly.

--

--