I think you have heard the news that Google is now supporting the Android app bundle for the release on Google Play. So what is the app bundle? should you use it in your app? Let's try to answer these questions in this blog post.
Until now, we have used APK to distribute our apps. APK is just a package of all our classes, library and resources files. But there are some downsides to using APK.
To solve these problems, google introduced Android app bundle. It solves these problems by introducing dynamic feature delivery and modularising the app.
Android app bundle is nothing but a set of multiple apk combined into one. When we create an android app bundle, under the hood android create multiple apk for the different module and serve them as needed by the user. Every app bundle always have one apk called base apk and it contains all the code that will be served to the user when downloaded for the first time.
We can conclude the following things from the image above.
The simplest way to get started with android app bundle using the android studio is
To add a new module follow these steps
6. Check new module called "adminfeature" is created on the left navigation panel. If you open the manifest file of this module, you will notice the following things.
<code><manifest xmlns:android="<http://schemas.android.com/apk/res/android>" xmlns:dist="<http://schemas.android.com/apk/distribution>" package="com.example.adminfeature"> <dist:module dist:instant="false" dist:title="@string/title_adminfeature"> <dist:delivery> <dist:on-demand /> </dist:delivery> <dist:fusing dist:include="true" /> </dist:module></manifest></code>
Let's break down all the things that this file is telling us.
For installing the dynamic feature, use play core library. It accesses the google play store.
<code>// This dependency is downloaded from Google’s Maven repository.// So, make sure you also include that repository in your project's build.gradle file.implementation 'com.google.android.play:core:1.7.3'</code>
<code>// Creates an instance of SplitInstallManager.SplitInstallManager splitInstallManager = SplitInstallManagerFactory.create(context);</code>
<code>// Creates a request to install a module.SplitInstallRequest request = SplitInstallRequest .newBuilder() // You can download multiple on demand modules per // request by invoking the addModule method .addModule("pictureMessages") .addModule("promotionalFilters") .build();</code>
<code>splitInstallManager .startInstall(request) .addOnSuccessListener(sessionId -> { ... }) .addOnFailureListener(exception -> { ... });</code>
<code>// You can specify more than one module at a time.splitInstallManager.deferredInstall(Arrays.asList("promotionalFilters"));</code>
There are mainly two ways to test your android app bundle. You can either change your run configuration in an Android studio and use that, or you can upload it on Google Play console internal track and then test it.
Or you can upload your app bundle to the internal track, and your tester can go to the link, which will contain the bundle for testing, and Google Play will serve the app bundle accordingly.
I have created this exampl
e application for the reference. It has two button
You can check out this application repository on Github.
In this blog post, we have learned about the android app bundle. We have learned how it works, how to build and install it in runtime, and also how we can test it. I hope you have found this article helpful if you have any query or suggestion for me,
let me know in the comment section below.
Thanks!! Have a nice day.