
What is SplitInstallManager?
SplitInstallManager is a part of the Play Core SDK that helps developers manage dynamic feature modules in Android apps. It is a tool that allows you to download, install, and manage optional feature modules after the initial app installation. By using this manager, apps can implement modular delivery using Android App Bundles, allowing apps to remain small and agile while delivering rich functionality on demand.
🚀 Key Features:
- On-demand feature delivery: Download features only when they are required by the user.
- Modularization: Helps developers split large APKs into smaller modules, improving app size.
- Background installation: Installs modules in the background without interrupting user experience.
- Seamless user experience: Once installed, features can be seamlessly integrated into the app.
Major Use Cases of SplitInstallManager
âś… 1. Modular App Design
SplitInstallManager allows large applications to be broken into multiple modules, allowing only the necessary modules to be downloaded on demand. This reduces initial APK size and improves performance.
âś… 2. On-Demand Feature Installation
Apps can have optional features that are not immediately necessary. For example, an app could have a heavy map or media module that users can choose to download when needed.
âś… 3. E-commerce Apps with Seasonal Features
E-commerce apps can offer seasonal promotions or large modules (like catalogs or ads) that only get installed when the user opts into them.
âś… 4. Games with Expansions or Add-Ons
Game developers can use SplitInstallManager to download additional levels or packs only when the user progresses through certain stages, saving on initial download size.
âś… 5. Geography-Specific Data
In apps that serve multiple countries or regions, certain localized features or data sets can be downloaded as needed, rather than bundling everything into the app initially.
How SplitInstallManager Works (Architecture Overview)
SplitInstallManager is part of Google Play Core SDK, which is responsible for handling modular app delivery through Android App Bundles.
đź§© Key Components:
- Feature Modules:
- Defined in the app’s Android App Bundle.
- Can be installed on-demand using
SplitInstallManager
. - Features can be installable or removable without affecting the main app.
- SplitInstallManager (Client-Side):
- Manages requests to download and install specific modules.
- Uses the
SplitInstallRequest
class to specify the modules to install. - Uses
SplitInstallSessionState
to monitor installation progress.
- Google Play Store (Server-Side):
- Handles the distribution of feature modules.
- Downloads only the requested modules, ensuring that unnecessary data is not installed.
🔄 How It Works:
- The user requests a feature (e.g., a map or additional levels in a game).
- The SplitInstallManager initiates the download of the module from Google Play.
- The module is installed in the background, and once the installation is complete, the user is notified.
- The feature is then ready for use in the app without restarting or interfering with the current user flow.
Architecture Flow:
- User Request: The app requests a feature module via
SplitInstallManager
when needed. - Install Request: The manager checks if the module is already installed. If not, it triggers a background installation.
- Download Process: The module is downloaded from Google Play.
- Installation Completion: Once installation is done, the module is ready for use, and the app can call it via the corresponding API.
Basic Workflow of SplitInstallManager
Here’s how a typical SplitInstallManager workflow looks in an Android app:
- User Requests a Feature (e.g., “Download more maps” or “Unlock new game levels”).
- SplitInstallManager checks if the feature module is already installed.
- If not installed, SplitInstallManager sends an install request to Google Play.
- Google Play downloads the module in the background without interrupting the user.
- Once installed, the feature is ready to use.
Step-by-Step Getting Started Guide for SplitInstallManager
Let’s walk through integrating SplitInstallManager into your Android project.
âś… Step 1: Set Up Your Android Project
- Start by creating a new Android App project in Android Studio.
- Configure the project to use Android App Bundles (
.aab
). - Add the necessary dependencies to your
build.gradle
:
dependencies {
implementation 'com.google.android.play:core:1.10.3'
}
âś… Step 2: Define Feature Modules
- Create a new Dynamic Feature Module in Android Studio:
- Go to File → New → New Module.
- Choose Dynamic Feature Module.
- Assign a module name (e.g., “maps”).
- Define the features in the
AndroidManifest.xml
of your dynamic module.
âś… Step 3: Initialize SplitInstallManager
In your main app module, initialize the SplitInstallManager:
SplitInstallManager splitInstallManager = SplitInstallManagerFactory.create(context);
âś… Step 4: Request Installation of a Feature Module
To request the installation of a module, use the following code:
SplitInstallRequest request = SplitInstallRequest.newBuilder()
.addModule("maps")
.build();
splitInstallManager.startInstall(request)
.addOnSuccessListener(sessionId -> {
// Handle success
})
.addOnFailureListener(exception -> {
// Handle failure
});
This triggers the background download of the maps
module.
âś… Step 5: Monitor Installation Progress
You can monitor the installation process using SplitInstallSessionState
:
splitInstallManager.registerListener(sessionState -> {
int status = sessionState.status();
if (status == SplitInstallSessionStatus.COMPLETED) {
// Module installed, ready to use
}
});
âś… Step 6: Load the Installed Feature Module
Once the module is installed, you can load and use it in your app:
if (splitInstallManager.getInstalledModules().contains("maps")) {
// Feature module is installed, load it
}
âś… Step 7: Handle Module Removal (Optional)
To uninstall a module:
splitInstallManager.deferredUninstall(Arrays.asList("maps"))
.addOnSuccessListener(aVoid -> {
// Module removed successfully
})
.addOnFailureListener(exception -> {
// Handle failure
});