Which Language is Good for Android by Analyze APK sizes?

0
1288

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.

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.

Which Language is Good for Android by Analyze APK sizes?
Which Language is Good for Android by Analyze APK sizes?

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.

  • For this test I created four different versions of the app, one in each of Java, Kotlin, React Nativeand 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.

1Java (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.

See this also : How Kotlin remove Java defects?

2Kotlin (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.

3React 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)

Recommended article : Comparison of All Android Dependency Injection

4Flutter.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.

Helping library : FileStack Android : Amazing Cloud File Picker

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.ioand 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.

Share your thoughts

Loading Facebook Comments ...
Loading Disqus Comments ...