Android APK's & Bundles: The Differences Explained
I recently linked a Android Application to the Visual Studio App Center for the first time.
In case you haven't had the chance to explore Microsoft's VS App Center yet, it's a developer service portal that allows you to build, test, release and monitor both desktop and mobile apps. Especially useful for recording analytics and crash reports from your apps. Not to mention the features for automated testing and releasing of your application.
When setting up the build configuration, I noticed this button to configure bundling in addition to generating an APK file.
I wasn't aware of the difference between APK'S and bundles and so I did some investigations before deciding to share my findings with you.
What Are APK's?
APK files (Android Package Kit) are the format of files used by Android to distribute and install apps. You can place APK files onto your Android device and run them much like you would an EXE file on Windows.
When you download an app from the Google Play Store, the .apk file is downloaded for you and installed. Various sites on the internet distribute .apk files for sideloading apps onto your device.
As a developer of Android apps, you will generate an .apk file when you debug your application and when you build it. The .apk file should just include the assets and code necessary for the app to function correctly.
You can distribute your app on the Google Play store with the APK file. However I'll shortly explain the reasons why you might use a bundle when distributing your app to the Play Store, instead of using the APK.
What Are App Bundles?
Android app bundles are packages that contain all of the compiled code and assets of your application, all bundled together in a .aab file format.
These bundles will not install or run if you place them on an Android device.
The idea is that you will upload this bundle to the Google Play Store. Google will then take your code and assets, then when a user tries to download your app Google will distribute an optimised build of the .apk file that is best suited for the user's device.
One of the main benefits to this kind of optimised build is that the .apk file can be tailored and the file size reduced. Since many users are constrained for space on the mobile devices, we as developers should always be looking to optimise our applications to use-up as little space as possible. You will also find that people will often be more likely to download your app if it isn't bloated.
Should I use an APK or a Bundle?
If you are building an Android app and wish to share it with others outside of the app store, then the .apk file will be more than sufficient. However, when you are listing the app on the Google Play Store, chose the bundle.
The App Bundle Format Explained
App bundles are signed binaries that organise your code and assets into modules. I may discuss the format further in a future blog post.
By digitally signing your bundle before submitting your .aab file to the Google Play Store, we can offer some guarantee that future updates using the correct key are trustworthy.