The second Android 11 Developer Preview is now available, test it out and share your feedback.

FakeSplitInstallManagerFactory

public class FakeSplitInstallManagerFactory
extends Object

java.lang.Object
   ↳ com.google.android.play.core.splitinstall.testing.FakeSplitInstallManagerFactory


Creates instances of FakeSplitInstallManager.

Summary

Public constructors

FakeSplitInstallManagerFactory()

Public methods

static FakeSplitInstallManager create(Context context)

Creates a fake implementation of the SplitInstallManager.

static FakeSplitInstallManager create(Context context, File modulesDirectory)

Alternative version of create(Context) which allows for the splits directory to be set explicitly.

Inherited methods

From class java.lang.Object

Public constructors

FakeSplitInstallManagerFactory

FakeSplitInstallManagerFactory ()

Public methods

create

FakeSplitInstallManager create (Context context)

Creates a fake implementation of the SplitInstallManager.

This implementation is self-contained and obtains splits from a specified directory, which can be populated passing the --local-testing flag to bundletool build-apks and using bundletool install-apks to install the app.

It is provided for testing, e.g. checking sequences of events when installing dynamic features and additional languages. It is suitable for use in integration tests.

This fake supports just one install request at a time.

Network errors can be simulated using setShouldNetworkError(boolean).

SplitCompat must be installed appropriately to use this class.

This method will always return the same FakeSplitInstallManager instance.

Parameters
context Context

Returns
FakeSplitInstallManager

create

FakeSplitInstallManager create (Context context, 
                File modulesDirectory)

Alternative version of create(Context) which allows for the splits directory to be set explicitly.

The constructor receives the directory on the device where the split apks can be obtained. The file name format is the same as the extracted output of bundletool build-apks. The apks in the directory must be signed by the same certificate as the app. If this directory is missing, install requests will fail with API_NOT_AVAILABLE.

In general, all configuration splits for the module that are present in the folder will be included. Thus, consider pre-filtering them for the device - e.g. using appropriate bundletool build-apks argument. However, since languages can change over time on the device, there will be additional filtering of language splits, whereby only appropriate languages will be included.

Prefer using create(Context) and let bundletool populate the default directory, unless there's a good reason to use a different directory or filter the delivered APKs by hand.

This method will always return the same FakeSplitInstallManager instance. It will fail if called twice with different directories.

Parameters
context Context

modulesDirectory File

Returns
FakeSplitInstallManager