Search Unity

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).

 

Comments are closed.

  1. Mahesh Khambadkone

    November 15, 2018 at 6:12 pm

    We frequently end up having to create AssetBundles, and their management (downloads, updates) is often cumbersome. Would be good to have tighter integration between Unity Asset Bundles and Android App Bundles.
    These could be entire folders of assets, a “Resource”/”StreamingAssets” folder or sets of Scenes, delivered as App Bundles.

  2. I have read the post and got to know that the Android app bundle is the complete package which is needed to build an android application. The android bundle is directly connected to the google server and you will directly get an update from Google. Contact error code 0xc00000f for more information.

  3. In the real world, there is currently only one Android architecture – arm32 (unless you already have a significant number of arm64 customers with reasons for a separate binary, or live in a parallel universe where MIPS is still a thing.) So I’m not sure how much this current implementation gains us, since Unity doesn’t really use the Android resource infrastructure directly (and shouldn’t).

    An implementation where you can build for low end devices assuming QualitySettings.masterTexturelimit > 0 would mean we could build bundles for low end devices without including all the top-level mipmaps in the build would be interesting. But without something like that, it only really becomes interesting from a code size perspective in fall 2019 when Google mandates arm64 code.

    1. Hi Leona,
      Moving to 64-bit is really about future proofing your games.
      More and more devices are 64-bit capable, new flagship phones are 64-bit capable. Our stats shows about 15% of game installs use 64-bit architecture on Android already. So we think “now” is really a good time to start your transition to 64-bit, before it’s motivated by store submission rules ;-)

      And we agree that quality settings, being able to target low-end / high-end with different sets of assets is a good idea. We are exploring this option.
      Thanks for your contribution ;-)
      JC

  4. This is great. It is clear app sizes are important for mobile, and Unity has issues in this area, but I’m sure the company are working on it, but it is not clear what is happening. I would love to see a blog post dedicated to improvements on the way, and what the latest advice is in this area for Android and iOS (e.g. the Unity manual advice on build sizes talks as if there is only .Net 2.0, what impact does the newer versions have?).

    1. Hi Moonjump,
      We are working on optimizing build sizes, Code Stripping option helps reduce the size for example.
      I recognize that we need to provide more guidance and explanation on how to optimize build sizes, but rest assured we are not ignoring it.
      Thanks for your comment
      JC

  5. Awesome! It will be nice if we can put it HD textures and normal textures

    1. Hi Suduck,
      Thanks for the suggestion. We are exploring these options.
      JC