ApplicationAndroidResources

Added in 8.4.0

@Incubating
interface ApplicationAndroidResources : AndroidResources


Build-time properties for Android Resources inside a Component. Specialization of AndroidResources for modules that applied the com.android.application plugin.

This is accessed via GeneratesApk.androidResources

Summary

Public properties

Boolean

Read-only property that automatically generates locale config when enabled.

SetProperty<String>

Specifies a list of locales that resources will be kept for.

Inherited properties

From com.android.build.api.variant.AndroidResources
ListProperty<String>

The list of additional parameters to pass to aapt.

Boolean

Flag indicating whether databinding feature is on

ListProperty<String>

The list of patterns describing assets to be ignored.

ListProperty<String>

File extensions of Android resources, assets, and Java resources to be stored uncompressed in the APK.

Boolean

Flag indicating whether viewbinding feature is on

Public properties

generateLocaleConfig

Added in 8.4.0
val generateLocaleConfigBoolean

Read-only property that automatically generates locale config when enabled.

To set it, use ApplicationAndroidResourcesBuilder.generateLocaleConfig in a AndroidComponentsExtension.beforeVariants callback.

localeFilters

Added in 8.9.0-alpha06
val localeFiltersSetProperty<String>

Specifies a list of locales that resources will be kept for.

For example, if you are using a library that includes locale-specific resources (such as AppCompat or Google Play Services), then your APK includes all translated language strings for the messages in those libraries whether the rest of your app is translated to the same languages or not. If you'd like to keep only the languages that your app officially supports, you can specify those languages using the localeFilters property, as shown in the sample below. Any resources for locales not specified are not included in the build.

androidComponents {
onVariants(selector().withName("release")) { variant ->
// Keeps language resources for the locales specified below.
variant.androidResources.localeFilters.addAll("en-rGB", "fr")
}
}

The locale must be specified either as (1) a two-letter ISO 639-1 language code, with the option to add a two-letter ISO 3166-1-alpha-2 region code preceded by "-r" (e.g. en-rUS), or (2) a BCP-47 language tag, which additionally allows you to specify a script subtag (e.g. b+sr+Latn+RS).

For more information on formulating locale qualifiers, see "Language, script (optional), and region (optional)" in the alternative resources table.