Support for Android App Bundle (AAB) in Unity 2018.3 beta
Larger apps and games convert fewer Google Play store visits into installs. This is because users are conscious of using up storage on their device, using up their data plans, and waiting around for downloads to complete on slow connections. Android App Bundle is a new Android app publishing format which makes games smaller on people’s device.
In Unity 2018.3 beta, we are introducing App Bundle support for some of the hardware configurations. Read on to learn how you can get started building an Android App Bundle instead of an APK! Larger games tend to be uninstalled first when users are looking to free up space on their device. This impacts users in all markets and is especially pronounced in markets where device storage and data is at a premium.
Android App Bundle includes all your game’s compiled code and resources, but defers APK generation and signing to Google Play. Google Play’s new app serving model, called Dynamic Delivery, then uses your app bundle to generate and serve optimized APKs for each user’s device configuration, so they download only the code and resources they need to run your app. You no longer have to build, sign, and manage multiple APKs to support different devices, and users get smaller, more optimized downloads.
Android App Bundles have multiple options to generate configuration APKs for each set of language resources, screen density resources, and ABI (Application Binary Interface, one for each combination of CPU and instruction sets), as well as of a new concept of Dynamic Features – see Google documentation for details.
In Unity 2018.3, we are introducing App Bundle support for CPU architecture/ABI (ARMv7, ARM64 & x86) and we’re exploring additional targeting dimensions that will be useful for developers so we welcome your feedback. We’d love to get your opinion on our Android Developer Forum!
Building the Android App Bundle
First, open your project in Unity 2018.3 beta. To build an Android App Bundle (AAB) instead of an APK, open the Build Settings window (menu: File > Build Settings), and tick the Build App Bundle checkbox (the Build System needs to be Gradle which is the default option):
If you select Build Unity will generate the AAB file which can be published directly to Google Play.
If you select Build and Run, Unity will generate the AAB file, then it will generate temporary APK file(s) specific for the attached device, install them on your device and run your application.
If you select Build and want to install the app to a device manually you can use bundletool utility provided by Google (it can be found in Editor/Data/PlaybackEngines/AndroidPlayer/Tools directory of your Unity installation). You can read here about bundletool flags and options.
Note that option Split APKs by target architecture (Edit > Setting > Player) is disabled when building app bundle because generated app bundle should include libraries for all supported targets.
Tips & tricks
During development, to decrease the iteration time when using Build and Run, it may be a good idea to disable app bundle generation and use a regular APK instead, because it takes additional time to generate APKs from an app bundle before deploying them to a device.
An app bundle can also be generated from Android Studio, with Gradle project exported from Unity. For this you need to use Android Studio 3.2 or later and just select Build > Build Bundle(s) / APK(s) > Build Bundle(s).
If you are targeting stores which don’t support Android App Bundles (currently it’s only supported by Google Play), you may want to use the Split APKs by target architecture option (in Player settings) instead to deliver APKs split by the CPU architecture of the end user device, or use the bundletool, which also allows you to build a “universal APK” that can run on any environment (see Android App Bundle doc).