Comparing APK sizes

For apps in Flutter, React Native, Kotlin and Java

Dharmin Majmudar
AndroidPub

--

There are so many ways to make mobile apps ranging from direct platform specific development (using Java and Kotlin for Android, and ObjC and Swift for iOS), there’s React Native from Facebook, Electrode Native from Walmart, the Ionic framework, Unity for certain types of apps, and the flutter.io framework which was just released by Google.

Update: Minimal APK sizes for Flutter applications went down!! “Overall release APKs are now 2MB smaller with those improvements. This brings the release APK size of a minimal Flutter app down to 4.7MB (from previously 6.7MB)”. — https://github.com/flutter/flutter/issues/16833#issuecomment-410103493

Ever wondered how these libraries and frameworks affect the size of your app? Let’s analyze some apk files for apps written in some of these ways. The apps are very basic, containing just a title at the top and a text at the center of the screen. This will show, for a bare minimum app what these frameworks need to package along with the apk for it to be able to run.

Simple Hello World app
  • For this test I created four different versions of the app, one in each of Java, Kotlin, React Native, and Flutter. (Android API 27)
  • The apks were then published for release type using Android Studio for Java and Kotlin and using the cli for React Native and Flutter.
  • Default proguard configuration was used.
  • The apks were analyzed using the Analyze APK feature in Android Studio.

Java (539 KB)

Lets start with the simplest one — Java. As you would expect this would be the smallest in size given that we are using just Java and the Android framework to create this app, with the only dependency being the Android Support Library, which you can see here takes up quite a lot of space.

We could potentially bring the app size down by removing this only dependency and using Activity instead of AppCompatActivity.

Kotlin (550 KB)

Next up, the fancy kid on the block — Kotlin. If you have been coding a long time in Java, Kotlin is a breath of fresh air. The release apk for the Kotlin app comprises of everything that we saw in the Java apk, plus a tiny portion of Kotlin based syntactic sugar info.

React Native (7 MB)

If you are coming from the web world and want to do most of the mobile development using javascript React Native is your go to option. It is also helpful if you want to iterate faster on a feature without releasing the app for every little change.

The release apk generated by React Native has a few classes in the classes.dex file that have 12193 referenced methods for this particular app.

Apk breakdown for Hello World in React Native (classes.dex)

It also adds some native dependencies in the lib directory for x86 and armeabi-v7a. Adding up to around 6.4 MB of dependencies in total.

Apk breakdown for Hello World in React Native (native dependencies)

Flutter.io (7.5 MB)

The release app generated by Flutter’s cli contains the C/C++ engine and the Dart VM which makes up almost all the of the apk. The app directly runs using the native instruction set and no interpreter is involved.

Apk breakdown for Hello World in Flutter

Every method of writing the app has its pros and cons (a future post will debate the pros/cons for each of these). Choose the method that makes the most sense for your use case and for your company. You can also mix and match some of these frameworks to make different parts of your app.

For example, if you are experimenting something make that component in React Native, if you want to share code between the iOS and Android app look into either React Native or Flutter.io, and if you are just focusing on Android and keeping the app size to a minimum is very critical you can go with either Java or Kotlin.

--

--

Dharmin Majmudar
AndroidPub

Android human loving all things Android since 2010. Apart from geeky stuff I like looong drives and reading non-fiction books.