Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Diving into Android App Bundle

Diving into Android App Bundle

Android app bundle (.aab) it's a new publishing format for android apps. This presentation handles all that is involved from dynamic delivery, split APKs, bundletool and dynamic features.

Omolara Adejuwon

November 03, 2018

More Decks by Omolara Adejuwon

Other Decks in Programming


  1. The Android App Bundle (.aab) is a new upload/publishing format.

    It mirrors the .apk format with a little bit of ‘stew’ ;)
  2. What is the need? • It makes the support of

    different configurations better - Dynamic delivery • Your users have a smaller APK to download • It favors modularization i.e cleaner code base • Leads us to dynamic features • Google Play console handles the serving for you Lagos
  3. Dynamic delivery serves only those files to the users which

    they need and this is what allows us to make apps smaller
  4. • A fundamental component of Dynamic Delivery. • Available on

    L+. • With split APKs Google Play can break up a large app into smaller packages that are installed on a user's device based on device’s configuration Split APKs
  5. • Base APK: contains all common code and resources •

    Configuration APKs: contains resources based on device’s config i.e locale, architecture, screen density • Dynamic Feature APKs: contains codes that can be downloaded at a later time. This will be discussed later in the presentation. 3 Kinds of Split APKs
  6. 12 android{ ... bundle { language { /* This property

    is set to true by default. Specifies that the app bundle should not support configuration APKs for language resources. These resources are instead packaged with each base and dynamic feature APK.*/ enableSplit = false } density { enableSplit = true } abi { enableSplit = true } } } Version 3.2+ + /app/build.gradle
  7. • Using Bundletool • Google Play console - Internal test

    track Testing App Bundles * App Bundles are not installable until they are signed
  8. 14 java -jar bundletool build-apks --bundle=PATH_TO_APP_BUNDLE \ --output=PATH_TO_OUTPUT_APKS --ks=PATH_TO_KEYSTORE \

    --ks-pass=pass:KEYSTORE_PASSWORD --ks-key-alias=KEY_ALIAS \ --key-pass=pass:KEY_PASSWORD --overwrite Bundletool -> Generate APKs http://github.com/google/bundletool https://developer.android.com/studio/command-line/bundletool
  9. 15 java -jar bundletool install-apks --apks=PATH_TO_OUTPUT_APKS Bundletool -> Install on

    connected device http://github.com/google/bundletool https://developer.android.com/studio/command-line/bundletool
  10. Enroll in Google Play App Signing Create and manage your

    releases - upload app bundle Google Play serves APKs to devices as required Publishing App Bundles
  11. It allows you break your app into modules/features. Your app

    handles the download and installation of each module when the user needs it. The core of this mechanism is the Play core library. This further helps your initial app size really small
  12. • How many % of your users really need that

    feature? • How large is the feature? • Can your users wait a few seconds to download that feature? When to use dynamic features
  13. 22

  14. 23

  15. 32 val manager = SplitInstallManagerFactory.create(this) //check if module has already

    been installed if (manager.installedModules.contains(module_name)) { //load the module }
  16. 33 val manager = SplitInstallManagerFactory.create(this) if (manager.installedModules.contains(module_name)) { //load the

    module } // Create request to install a feature module by name. val request = SplitInstallRequest.newBuilder() .addModule(module_name) .build()
  17. 34 val manager = SplitInstallManagerFactory.create(this) if (manager.installedModules.contains(module_name)) { //load the

    module } // Create request to install a feature module by name. val request = SplitInstallRequest.newBuilder() .addModule(module_name) .build() // Load and install the requested feature module. manager.startInstall(request) .addOnSuccessListener {} .addOnFailureListener {}
  18. 35 val listener = SplitInstallStateUpdatedListener { state -> state.moduleNames().forEach {

    name -> // Handle changes in state. when (state.status()) { SplitInstallSessionStatus.DOWNLOADING -> {} SplitInstallSessionStatus.REQUIRES_USER_CONFIRMATION -> { /*This may occur when attempting to download a large module like 10MB */ startIntentSender(state.resolutionIntent()?.intentSender, null, 0, 0, 0) } SplitInstallSessionStatus.INSTALLED -> {} SplitInstallSessionStatus.INSTALLING -> {} SplitInstallSessionStatus.FAILED -> {} } } }
  19. 37 //defer installation of some modules manager.deferredInstall(modules).addOnSuccessListener {} //uninstall modules

    that are no more needed val installedModules = manager.installedModules.toList() manager.deferredUninstall(installedModules).addOnSuccessListener {}