Splits

@Incubating interface Splits
com.android.build.api.dsl.Splits

DSL object for configuring APK Splits options. Configuring this object allows you to build Multiple APKs and Configuration APKs.

If your app targets multiple device configurations, such as different screen densities and Application Binary Interfaces (ABIs), you might want to avoid packaging resources for all configurations into a single large APK. To reduce download sizes for your users, the Android plugin and Google Play Store provide the following strategies to generate and serve build artifacts that each target a different device configuration--so users download only the resources they need:

  • Multiple APKs: use this to generate multiple stand-alone APKs. Each APK contains the code and resources required for a given device configuration. The Android plugin and Google Play Store support generating multiple APKs based on screen density and ABI. Because each APK represents a standalone APK that you upload to the Google Play Store, make sure you appropriately assign version codes to each APK so that you are able to manage updates later.
  • Configuration APKs: use this only if you're building Android Instant Apps. The Android plugin packages your app's device-agnostic code and resources in a base APK, and each set of device-dependent binaries and resources in separate APKs, called configuration APKs. Configuration APKs do not represent stand-alone versions of your app. That is, devices need to download both the base APK and additional configuration APKs from the Google Play Store to run your instant app. The Android plugin and Google Play Store support generating configuration APKs based on screen density, ABI, and language locales. You specify properties in this block just as you would when building multiple APKs. However, you need to also set generatePureSplits to true.

Summary

Public methods

abstract Unit
abi(action: AbiSplit.() -> Unit)

Encapsulates settings for <a building per-ABI APKs.

abstract Unit
density(action: DensitySplit.() -> Unit)

Encapsulates settings for building per-density APKs.

Properties

abstract AbiSplit

Encapsulates settings for building per-ABI APKs.

abstract Collection<String>

Returns the list of ABIs that the plugin will generate separate APKs for.

abstract DensitySplit

Encapsulates settings for building per-density APKs.

abstract Collection<String>

Returns the list of screen density configurations that the plugin will generate separate APKs for.

Public methods

abi

abstract fun abi(action: AbiSplit.() -> Unit): Unit

Encapsulates settings for <a building per-ABI APKs.

For more information about the properties you can configure in this block, see AbiSplit.

density

abstract fun density(action: DensitySplit.() -> Unit): Unit

Encapsulates settings for building per-density APKs.

For more information about the properties you can configure in this block, see DensitySplit.

Properties

abi

abstract val abi: AbiSplit

Encapsulates settings for building per-ABI APKs.

abiFilters

abstract val abiFilters: Collection<String>

Returns the list of ABIs that the plugin will generate separate APKs for.

If this property returns null, it means the plugin will not generate separate per-ABI APKs. That is, each APK will include binaries for all ABIs your project supports.

Return
a set of ABIs.

density

abstract val density: DensitySplit

Encapsulates settings for building per-density APKs.

densityFilters

abstract val densityFilters: Collection<String>

Returns the list of screen density configurations that the plugin will generate separate APKs for.

If this property returns null, it means the plugin will not generate separate per-density APKs. That is, each APK will include resources for all screen density configurations your project supports.

Return
a set of screen density configurations.