An easy way to test offline dynamic delivery

Kenji Abe
2 min readFeb 8, 2020

--

Photo by Green Chameleon on Unsplash

bundletool is a tool for local testing android app bundle. It also can be used for testing offline dynamic delivery.

FakeSplitInstallManager will achieve testing offline dynamic delivery.

I will show an easy way to test offline dynamic delivery.

Usage FakeSplitInstallManager

It’s easy. It just use FakeSplitInstallManagerFactory instead of SplitInstallMangaerFactory.

FakeSplitInstallManagerFactory.create(
context,
context.getExternalFilesDir("local_testing")
)

The second argument is important for testing. You need to specify the directory which includes splits APK files. In the above code, it’s local_testing in the app-specific file directory. local_testing must not change because bundletool uses its name.

Usage bundletool

Downloading bundletool from Github release page.

See the document for details.

Generate a set of APKs

For using FakeSplitInstallManager, you need to add --local-testing option.

$ bundletool build-apks --bundle=bundle.aab \
--output=app.apks \
--ks=keystore.jks \
--ks-pass=pass:store_password \
--ks-key-alias=key-alias \
--key-pass=pass:key_password \
--connected-device \
--local-testing

--local-testing option is added since version 0.13.0.

Deploy APKs

$ bundletool install-apks --apks=app.apks

If you add --local-testing when generating APKs, bundletool pushes apk files to thelocal_testing directory on a connected device.

These apk files are used by FakeSplitInstallManager for testing offline dynamic delivery.

Finally, you launch your app and then execute a dynamic feature module installation. You can test without Google Play.

Conclusion

You can test offline dynamic delivery in 3 steps.

  1. Use FakeSplitInstallManager instead of SplitInstallMangaer.
  2. Generate a set of APKs with --local-testing option.
  3. Deploy APKs.

--

--

Kenji Abe
Kenji Abe

Written by Kenji Abe

Programmer / Gamer / Google Developers Expert for Android, Kotlin / @STAR_ZERO

Responses (1)