Reading Time: 5 minutes

AABs, APKs. What are them and what’s the difference?

When building Android Apps, you will be facing a myriad of different file formats and terminology. Particularly when exporting the final version of your app, you will be seeing two main output formats. In this post, we will compare Android App Bundle vs APK, which are composed of DEX files. But what do all these acronyms mean?

Acronym meaning

Before digging deeper into the topics it is important to get the definition of each of the above mentioned formats:

  1. AAB: Android App Bundle.
  2. APK: Android App Package.
  3. DEX: Dalvik Executable.
Photo by Austin Distel on Unsplash

APK: Android Application Package

Let’s begin by reviewing this format as it is the one that is most known and has been around for a longer time. As mentioned above, APK stands for “Android App Package“. An APK is basically a file that is ready to be installed on a user’s device.

APKs have all of the app’s files and code inside. You can think of it as a zip file but with its own particular extension. Just as you can find compressed files with extensions in .rar o .zip. There is one in .apk, which is mainly understood by the Android platform, but other platforms could support it if they had the same underlying architecture as Android does.

Photo by Charles Deluvio on Unsplash

The APK is already signed with the app’s certificate, which is a file that identifies every app in the PlayStore. This file has to be kept by the developers throughout the life of the app, as it is not possible to generate it again.

AAB: Android Application Bundle

AAB which stands for “Android Application Bundle” is a more recent format for Android distribution. Android’s official documentation, gives the following definition:

An Android App Bundle is a publishing format that includes all your app’s compiled code and resources, and defers APK generation and signing to Google Play.

https://developer.android.com/guide/app-bundle

These application bundles are fairly new, they were introduced in Google I/O 2018. They are about to get 2 years old. But ever since, they became the official format for publishing Android apps.

Just as the apk is an extension, AAB files also have the extension .aab. The Android documentation provides an image explaining how AABs are composed.

If you had an APK, you would only have the orange part of the app, which will have inside of itself all the assets, meaning you can only have one pack of them, and no dynamic features.

Asset Packs

Asset packs are groups of files targeted to a group of devices. When using a traditional APK, the app will receive all assets and just chose and use the ones that are necessary for that specific device. On the other hand, when using AAB, the PlayStore selects the assets that will be needed when the user downloads the app.

Dynamic Features

This features are modules that may not be needed on the first install of the app. You can either download them when the user requests to add that functionality or download the app and then start downloading them in the background to give the user a head-start on using your app.

To install dynamic features we have the “Split Install API” that will be managed by the “Play Core Library” which communicates directly to the Play Store.

Advantages of Android App Bundle vs APK

Android Stresses several disadvantages of using APKs:

  1. Lower conversion rates
  2. Slower downloads
  3. Higher uninstalls
  4. Lower update rates

Size

The first advantage is the size reduction. With asset packs and dynamic features apps become in average 35% smaller. But some apps have gotten a decrease in size of around 50%.

After the introduction of AABs the maximum size of an app is 150Mb. By using an APK you can easily surpass this requirement.

Photo by Rob Hampson on Unsplash

Uncompressed Native Libraries

For some reason, when you have an APK, the app gets a copy of all the native libraries that are needed in a compressed format. After the download, the device decompresses those libraries by creating a copy, because it can’t use them without decompression. In the end you will have two copies of the library.

When comparing Android App Bundle vs the APK, you will notice the AAB gets uncompressed native libraries by default, which will avoid having two copies in the end.

You might be wondering why does the APK keep both a copy of the compressed version and another for the uncompressed. This as the above mentioned items, is because the libraries are sometimes device specific. You may need a different one for each device, which the PlayStore can send to the device on download time if you are providing an AAB

What about DEX files?

Both APKs and AABs contain DEX files inside. Those files are the key to executing the code. These files are called Dalvik executable because inside the core of Android, there is something called Dalvik Virtual Machine. In simpler words, this Virtual Machine executes the code of the apps in Android to make them available to you.

ProTip: Error with Dex files

There is a common error in Android Studio when building your project. This error is easy to fix but can be frustrating if you don’t know what is it talking about. When trying to run the app you will get a message like the following.

Cannot fit requested classes in a single dex file

Gradle making us sad as always 🙁

If you are also getting this error go to build.gradle(Module: app) and inside the brackets of defaultConfig add the following line

multiDexEnabled true

Android Studio will request to sync the project as every time you do a change in Gradle files. Do the Gradle Sync and run the app.

Conclusion

As you can see comparing an Android App Bundle vs APK is not that complicated. App bundles have been around for almost two years and they are very useful to give users a better experience, so why not give them a try? I hope you add this to your next project! Let me know in the comments below if you have any questions. Join my email list at the bottom if you would like to receive more content like this.

Until next time!

Evana Margain Puig

(Visited 321 times, 2 visits today)