android_resource()
android_resource()
rule is used to bundle Android resources that are traditionally stored in res
and assets
directories.The output of an android_resource()
is an R.txt
file generated via aapt --output-text-symbols
.
Arguments
name
(required) #The short name for this build target.
res
(defaults toNone
) #A dictionary mapping relative resource paths to either the resource files or the build targets that generate them. The
subdir_glob()
function can be used to generate dictionaries based on a directory structure of files checked into the repository. Alternatively, this can be a path to a directory containing Android resources, although this option is deprecated and might be removed in the future.package
(defaults toNone
) #Java package for the
R.java
file that will be generated for these resources.assets
(defaults toNone
) #A dictionary mapping relative asset paths to either the asset files or the build targets that generate them. The
subdir_glob()
function can be used to generate dictionaries based on a directory structure of files checked into the repository. Alternatively, this can be a path to a directory containing Android assets, although this option is deprecated and might be removed in the future.project_res
(defaults toNone
) #A directory containing resources to be used for project generation. If not provided, defaults to whatever the build uses.
project_assets
(defaults toNone
) #A directory containing assets to be used for project generation. If not provided, defaults to whatever the build uses.
manifest
(defaults toNone
) #An optional Android Manifest for the resource to declare any permissions or intents it may need or want to handle. May either be a file or a
android_manifest
target.deps
(defaults toNone
) #Other
android_resource
rules to include via-S
when runningaapt
.visibility
(defaults to[]
) #List of build target patterns that identify the build rules that can include this rule as a dependency, for example, by listing it in their
deps
orexported_deps
attributes. For more information, see visibility.licenses
(defaults to[]
) #Set of license files for this library. To get the list of license files for a given build rule and all of its dependencies, you can use
buck query
.labels
(defaults to[]
) #Set of arbitrary strings which allow you to annotate a build rule with tags that can be searched for over an entire dependency tree using
buck query attrfilter()
.
Examples
Most of the time, anandroid_resource
rule defines only name
, res
, and package
. By convention, such simple rules are often named res
:android_resource( name = 'res', res = subdir_glob([('res', '**')]), package = 'com.example', )