Simple Guide To Building Your First Instant App
Android Instant Apps is an elegant solution allowing instantaneous launching of Android apps without installation.
To be honest, every developer wants to get his app in the hands of as many users as possible. Android Instant Apps make your Android app accessible and discoverable from any location supporting URLs. That creates new possibilities for users.
Let’s look at Instant Apps from the business perspective. Usually, a vendor’s goal is not the number of times the app is downloaded but the number of users who use the main functionality of the app. This makes Android Instant Apps really effective.
For example, we have an app for watching media content (video, music, pics). With this app, users are able to:
- Watch media files
- Load their files
- Download media files
- Share their media files with other people
Instant Apps allows dividing these features into separate units. As a result, users can use these units separately without individual installation. Imagine a situation where a user Googles “watch supernatural.” In the search results, a link to your app appears. By following this link, the user can get the necessary files to run a specific module for watching media files. At the same time, he doesn’t need to install anything on his device. By exiting app, he loses access to it. And he has to follow the link again to enter the application.
Instant Apps is imperative for business. Buyers don’t need to install “heavy” applications to purchase something in an online shop. The weight of each separate unit can’t exceed 4 mb. This allows users make mobile purchases using the main functionality of your app.
Additionally, businesses can use Google Nearby Notifications for promoting or pushing a URL to lead to their Android Instant app. Imagine a retail brand has an app allowing users to locate items they want to buy. Using Nearby Notifications, shoppers can launch the app and start using its functionality without having to install it. Since both native apps and Android Instant Apps provide the same user experience, there are no differences in them. However, with Android Instant Apps, you don’t have to install anything.
There are some peculiarities in developing Instant Apps. For example, each new feature should be placed in a separate unit with a full code, resources, and dependencies.
Let’s have a look at a simple guide to help you create your own Instant Apps project in Android Studio.
- You need Android Studio 3.0.
- In Android Studio, select “Start a new Android Studio project.”
3. Fill in the following fields: Application name, Company domain, project location, and Package name. Click the button “Next.”
4. In Target Android Devices, select “Phone and Tablet,” and “Include Instant App Support.” BTW, choose API 23. Click the button “Next.”
5. In Customize Instant App Support, fill in the field “Module Name.” Click the button “Next.”
6. In “Add an Activity to Mobile,” select “Empty Activity” and click the button “Next.”
7. In “Configure Activity,” fill in the field “Instant App URL Host.” This is the basic URL of your app. In the field “Instant App URL Route Type,” select “Path Pattern.” In the field “Instant App URL Route,”write an address to Activity. Fill in the field “Activity Name.” Push the button “Finish.”
8. Congrats! You’ve created your first Instant Apps Android application. It’s important to mention Instant App loads both the feature’s unit and the basic unit of the base. The unit of the base consists of general resources and components for all the units. If you look at the build.gradle file of unit base, you can see all the features units are in the field dependencies.
At this point, there is only one unit with a feature, which is known as a mainfeature and is shown in dependencies. When adding new features, we also need to add new dependencies in this block. Plus, we add instant and app into the block of dependencies build.gradle.
Let’s add a new feature into the project. We’ll need to:
- Click the button “FIle” and go to “New,” and “New Module.”
2. In “New Module,” select “Feature Module.”
3. In “Creates a new Android module,” fill in the fields “Application/Library name,” “Module name,” “Package name,” and “Minimum SDK.” Click the button “Next.”
4. In “Add an Activity to Mobile,” select “Empty Activity.” Click the button “Next.”
5. In “Configure Activity,” fill in the following fields “Instant App URL Host,” “Instant App URL Route Type,” “Instant App URL Route,” and “Activity Name.” Click the button “Finish.”
6. Go to build.gradle file of the app unit. In the block dependencies, add the line “implementation project(‘:secondfeature’).
7. Go to the build.gradle file of the instantapp unit. In the block dependencies, add the line implementation project(‘:secondfeature’).
8. New features units should be automatically added to the build.gradle. If not, implement items 6 and 7 for this file.
9. Click the button “Sync Now.”
10. Congrats! You’ve added a new feature to your Instant App.
Now we need to test our app. The easiest way is to create an emulator with version API SDK 26 or later. If you want to find out how to run projects on real devices or emulators with other versions of API, you can find all the necessary information here. To distinguish screens from mainfeature and secondfeature, you may change their xml layouts. We can either install a usual option of application or run a specific unit InstantApp. In order to run InstantApp, you need to choose the option “instantapp.”
Then, click the button “Run.”
Now you’ve run your mainfeature unit.
If you want to run another unit, you need to click on the chosen instantapp and select “Edit Configurations.”
There’s a field “URL” in “Run/Debug Configurations.” There you can see your mainfeature unit. That’s why it’s running while testing. If you want to run another unit, you need to change an address to the address of this unit. Then, click the button “Apply.”
Having run instantapp one more time, another unit is run.
The Bottom Line
Great job! You’ve successfully created your first Android Instant App. Many IT analysts are sure Android Instant Apps is a game changer for mobile app development. It provides some really cool features including:
- Running android apps as loading a webpage;
- The possibility of accessing an app from any place without installing it on your device
- Android Instant Apps are compatible with all the Android versions starting from Jelly Beans.
Hopefully, you found this guide useful. Share your opinion with us. Can you see yourself using them? Will you’ll convert your current apps or maybe use it for the Android Instant Apps for your future projects?