Instant Apps is a technology introduced over two years ago at Google IO. An Instant App is designed to give your users a native Android experience without them directly installing the app from the Play Store.
Essentially, this is how it works: You split your app into smaller pieces called Features, which you can locally bundle in a zip file called an instant bundle. Then you upload that bundle to the Play Store, which can then choose from the set of APK’s, and finally deliver to user devices.
The project structure of an Instant App initially looked something like this:
First of all, you had to take all of your base application code and move it from the application module to a base feature.
Then you had to split your app into a features module containing the features in your app. Not exactly ideal, as we needed to do so much work to achieve this.
Android App Bundle:
The new publishing format for Android apps is called Android App Bundle (AAB). And thankfully, it’s much better in optimizing our APK. But what if we move our Instant App using the app bundle, given that the feature plugin is deprecated now? Here’s what deprecation of this plugin means on a high-level:
- You don’t need to create a base feature module now.
- You don’t need to split your app into feature modules.
For more detailed info about this deprecated plugin, check out this post on the Android Developer’s Blog:
So let’s get started and see what we can do.
First, we need to make sure that we have the following things ready to go:
- Android Studio 3.3 or higher
- Google Play Instant Development SDK
If we’re creating a product from scratch, we need to select the checkbox ✅ as you can see below:
If you’re in an already-created project, you’ll need to simply add a module and select the Instant Dynamic Feature Module like below:
After adding the module, you’ll be able to see a folder for it your project. It will automatically add a module and their files.
Your Dynamic_Feature manifest file should have the following contents after you’ve added a module:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:dist="http://schemas.android.com/apk/distribution" package="com.foodup"> <dist:module dist:instant="true" dist:onDemand="false" dist:title="@string/title_dynamic_feature"> <dist:fusing dist:include="false" /> </dist:module> </manifest>
Enable Instant App:
Now, if Instant App is disabled in your device, you’ll need to first enable it before going for a test run. Just need to follow these guides
- Open “Settings” and find the “Google” settings tab.
- In Google settings, scroll down and select “Instant Apps”.
- Switch the tab to On to enable, and agree to the terms.
Test the Instant App experience:
Before publishing your app to the play store, you can test the Instant App experience on your device. For this, we have to follow these steps:
- Go to the Edit Configurations.
- Check ✅ Deploy as instant app.
- Hit ok.
- Run your application.
Instant App experiences are available only on devices running Android 5.0 (API level 21) or higher.
Here’s the result—You can see the experience of the Instant App without installing the app. In your application, you’ll see the instant icon showing like this.
This article described how you can create an Instant App experience using Android App Bundle, the new publishing format of Android Apps without doing too much work. Also, the feature plugin is deprecated now, and Google recommends that you use AAB when implementing Instant App.
I hope this article is helpful. If you think something is missing, have questions, or would like to give feedback, go ahead and leave a comment below. I’d appreciate the feedback.
I’ve written some other Android-related content, and if you liked what you read here, you’ll probably also enjoy this:
Sharing (knowledge) is caring 😊 Thanks for reading this article. Be sure to clap or recommend this article if you found it helpful. It means a lot to me.