Stay organized with collections
Save and categorize content based on your preferences.
Splits
@Incubating interface 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
Properties
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.
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. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# Splits\n======\n\n```\n@Incubating interface Splits\n```\n\n|---------------------------------------|\n| [com.android.build.api.dsl.Splits](#) |\n\nDSL object for configuring APK Splits options. Configuring this object allows you to build\n[Multiple APKs](https://developer.android.com/studio/build/configure-apk-splits.html) and\n[Configuration APKs](https://developer.android.com/topic/instant-apps/guides/config-splits.html).\n\nIf your app targets multiple device configurations, such as different screen densities and\n[Application Binary Interfaces (ABIs)](https://developer.android.com/ndk/guides/abis.html), you\nmight want to avoid packaging resources for all configurations into a single large APK. To reduce\ndownload sizes for your users, the Android plugin and Google Play Store provide the following\nstrategies to generate and serve build artifacts that each target a different device\nconfiguration--so users download only the resources they need:\n\n- [Multiple APKs](https://developer.android.com/studio/build/configure-apk-splits.html): 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](https://developer.android.com/studio/build/configure-apk-splits.html#configure-APK-versions) so that you are able to manage updates later.\n- [Configuration APKs](https://developer.android.com/topic/instant-apps/guides/config-splits.html): use this only if you're building [Android Instant Apps](https://developer.android.com/topic/instant-apps/index.html). 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`](https://google.github.io/android-gradle-dsl/current/com.android.build.gradle.BaseExtension.html#com.android.build.gradle.BaseExtension:generatePureSplits) to `true`.\n\nSummary\n-------\n\n| ### Public methods ||\n|---------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [abi](#abi(kotlin.Function1))`(`action:` `[AbiSplit](/reference/tools/gradle-api/4.2/com/android/build/api/dsl/AbiSplit).()` `-\u003e` `[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)`)` Encapsulates settings for \\\u003ca [building per-ABI APKs](https://developer.android.com/studio/build/configure-apk-splits.html#configure-abi-split). |\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [density](#density(kotlin.Function1))`(`action:` `[DensitySplit](/reference/tools/gradle-api/4.2/com/android/build/api/dsl/DensitySplit).()` `-\u003e` `[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)`)` Encapsulates settings for [building per-density APKs](https://developer.android.com/studio/build/configure-apk-splits.html#configure-density-split). |\n\n| ### Properties ||\n|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [AbiSplit](/reference/tools/gradle-api/4.2/com/android/build/api/dsl/AbiSplit) | [abi](#abi:com.android.build.api.dsl.AbiSplit) Encapsulates settings for [building per-ABI APKs](https://developer.android.com/studio/build/configure-apk-splits.html#configure-abi-split). |\n| abstract [Collection](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-collection/index.html)\\\u003c[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)\\\u003e | [abiFilters](#abiFilters:kotlin.collections.Collection) Returns the list of ABIs that the plugin will generate separate APKs for. |\n| abstract [DensitySplit](/reference/tools/gradle-api/4.2/com/android/build/api/dsl/DensitySplit) | [density](#density:com.android.build.api.dsl.DensitySplit) Encapsulates settings for [building per-density APKs](https://developer.android.com/studio/build/configure-apk-splits.html#configure-density-split). |\n| abstract [Collection](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-collection/index.html)\\\u003c[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)\\\u003e | [densityFilters](#densityFilters:kotlin.collections.Collection) Returns the list of screen density configurations that the plugin will generate separate APKs for. |\n\nPublic methods\n--------------\n\n### abi\n\n```\nabstract fun abi(action: AbiSplit.() -\u003e Unit): Unit\n```\n\nEncapsulates settings for \\\u003ca\n[building per-ABI APKs](https://developer.android.com/studio/build/configure-apk-splits.html#configure-abi-split).\n\nFor more information about the properties you can configure in this block, see [AbiSplit](/reference/tools/gradle-api/4.2/com/android/build/api/dsl/AbiSplit). \n\n### density\n\n```\nabstract fun density(action: DensitySplit.() -\u003e Unit): Unit\n```\n\nEncapsulates settings for\n[building per-density APKs](https://developer.android.com/studio/build/configure-apk-splits.html#configure-density-split).\n\nFor more information about the properties you can configure in this block, see\n[DensitySplit](/reference/tools/gradle-api/4.2/com/android/build/api/dsl/DensitySplit).\n\nProperties\n----------\n\n### abi\n\n```\nabstract val abi: AbiSplit\n```\n\nEncapsulates settings for\n[building per-ABI APKs](https://developer.android.com/studio/build/configure-apk-splits.html#configure-abi-split). \n\n### abiFilters\n\n```\nabstract val abiFilters: Collection\u003cString\u003e\n```\n\nReturns the list of ABIs that the plugin will generate separate APKs for.\n\nIf this property returns `null`, it means the plugin will not generate separate per-ABI APKs.\nThat is, each APK will include binaries for all ABIs your project supports.\n\n| Return ||\n|---|---|\n| a set of ABIs. ||\n\n### density\n\n```\nabstract val density: DensitySplit\n```\n\nEncapsulates settings for\n[building per-density APKs](https://developer.android.com/studio/build/configure-apk-splits.html#configure-density-split). \n\n### densityFilters\n\n```\nabstract val densityFilters: Collection\u003cString\u003e\n```\n\nReturns the list of screen density configurations that the plugin will generate separate APKs\nfor.\n\nIf this property returns `null`, it means the plugin will not generate separate per-density\nAPKs. That is, each APK will include resources for all screen density configurations your\nproject supports.\n\n| Return ||\n|---|---|\n| a set of screen density configurations. ||"]]